This project is archived and is in readonly mode.

#5672 ✓resolved

[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

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=""></a>

Referenced by