small medium large xlarge

Generic-user-small
23 Jan 2009, 18:19
KenA (16 posts)

ref. validates_length_of and trimming

hi. suppose i’m validating the length of a form field and it’s validating it for a 7 chars long, eg: validates_length_of :title, :minimum => 7

well, so i fill this form field with a 6 chars long word and add an extra space char in the end, then validation will consider a 7 chars long word because it doesn’t trimmed or right-trimmed it before validation

i could fix it in client-side with js or maybe run a before filter to trim it on the server side, but is there a better and nicer way to do it?

You must be logged in to comment