This project is archived and is in readonly mode.
[PATCH] Improved support for shortcut options to custom validators
Reported by Obie | September 21st, 2010 @ 02:50 AM
Because of the current implementation of _parse_validates_options, you can only "shortcut" options with arrays, ranges and regexes. This patch expands that feature to so that you can also send other types of objects including strings and numbers. They will be passed to the custom validator's initializer as options[:with], just like happens with regexes now.
# current functionality
validates :email, :format => /@/
validates :gender, :inclusion => %w(male female)
validates :password, :length => 6..20
# new functionality in this patch
validates :name, :like => "Report"
validates :number, :base => 10
Comments and changes to this ticket
-
Rohit Arondekar September 21st, 2010 @ 03:06 AM
- State changed from new to open
- Importance changed from to Low
The patch had trailing whitespace warnings. Attached is a new patch with those removed.
+1 on the patch.
-
Repository September 24th, 2010 @ 12:11 PM
- State changed from open to resolved
(from [275f922a23b780600a32f70de5b661371c8ffdf4]) Better shortcut options for custom validators [#5672 state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/275f922a23b780600a32f70de5b661...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 5672 [PATCH] Improved support for shortcut options to custom validators (from [275f922a23b780600a32f70de5b661371c8ffdf4]) Better ...