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 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.
On Sun, 24 Feb 2008 10:45:02 +0100
GA Gorter [email protected] 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs