i have a field in my sign up form . I have the reqiurement that my login field should not contain any dot in it
so in my model i wrote like
validates_inclusion_of :login, :in => %w(.), :message => "sho开发者_StackOverflow中文版uld not contain dot!"
Is this correct one ..
The above thing works for me .. but i dont know how is it working ...
As per the documentation 's inclusion should check for the characters inside and if not it should reject rite??
But how come its doing in reverse ??
Please give suggestions..
Maybe you should use something like this:
validates_format_of :login,
:with => /^[^\.]*$/,
:message => "should not contain dot!"
you can try this
validates :login, :format => { :with => /[^.]*/ }
精彩评论