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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Dharmdip Rathod at Feb 20, 2012 at 8:25 am
    Hi Venkat,

    Can you share exact code what have you written in model ?

    --
    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@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 13, '12 at 10:32a
activeFeb 20, '12 at 8:25a
posts2
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Dharmdip Rathod: 2 posts

People

Translate

site design / logo © 2021 Grokbase