On Sun, 24 Feb 2008 10:45:02 +0100
GA Gorter <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:
>
> I need a validates_format_of that disallow dots.
>
> In the api there is nothing to find about how validates_format_of exatly
> works.
> Is there a better documentation or is there something that can tell me
> howto disallow dots.
> --
I''m not sure how validates_format_of can be explained better than it is
in the API. You give it a field to validate, and you give it a regex that must
be matched for the field to be considered valid.
If literally your only requirement is that there are no dots then:
validates_format_of :field, :with => /\A[^.]+\Z/
which validates that field has at least 1 character between the start and end of
the string and that that character or characters are not dots, since the regex
calls for an unbroken string of "notdots" between start and end. For
more detail on how regular expressions work in ruby, you might want to look
here:
http://doc.infosnel.nl/ruby_regular_expressions.html
Hope this helps,
Jon
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---