From: Brian Candler Date: 2009-01-26T00:29:23+09:00 Subject: Re: regural expression with not condition. Vamsi Krishna wrote: > i'm trying validate the format which doesn't consist of an empty string > in the single or double quotes. > > validates_format_of :name,:with=>/^['"][ ]*['"]$/ ,:on=> :create > > /^['"][ ]*['"]$/ it does validation for like the string ' ' and " " . i > need except this like the string may contain "vamsi" or 'vamsi' or > "vamsi's" all these three are valid for me. What do you mean: the string may contain spaces, but must not start or end with one? > so how to modify the above expression is there any thing like > :without? (ofcourse there is no) Yes there is: validates_each :name do |record,attr,value| record.errors.add attr, 'is invalid' if value[0] =~ /some_regexp/ end -- Posted via http://www.ruby-forum.com/.