# Validates\_format\_of no dots allowed

**URL:** <https://www.ruby-forum.com/t/validates-format-of-no-dots-allowed/130015>\
**Category:** Rails\
**Created:** [February 24, 2008, 10:45am UTC](https://www.ruby-forum.com/t/validates-format-of-no-dots-allowed/130015 "2008-02-24T10:45:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [February 24, 2008, 10:45am UTC](https://www.ruby-forum.com/t/validates-format-of-no-dots-allowed/130015/1 "2008-02-24T10:45:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [February 24, 2008, 11:32am UTC](https://www.ruby-forum.com/t/validates-format-of-no-dots-allowed/130015/2 "2008-02-24T11:32:19Z")

</div>

On Sun, 24 Feb 2008 10:45:02 +0100  
GA Gorter [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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](http://doc.infosnel.nl/ruby_regular_expressions.html)

Hope this helps,  
Jon
