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.