I want to dynamically validate my password with validates_format_of .
validates_format_of :password,:with => need to get regular expression
dynamically based up on the object setting.
class Admin < AR::Base
validates_format_of :password,:with => lambda {|admin|
admin.get_regular_exp}
def get_regular_exp
self.advanced? ? /^[a-z]/ : /^[A-Z]/
end
end
when I run the application I am getting this error :
validates_format_of'': A regular expression must be supplied as the
:with
option of the configuration hash
I can still use this approach
validate :admin_password
But my client is very particular on using Rails default methods.
Is there any way to solve this issue.
Cheers,
Venkat.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.