This project is archived and is in readonly mode.

#2309 ✓resolved
Christopher Lee

validate_length_of :maximum fails on nil/empty value

Reported by Christopher Lee | March 21st, 2009 @ 07:21 PM

forgive me as I'm new to rails bugtracking.

the last bug I saw opened was http://dev.rubyonrails.org/ticke..., which was open and is still unresolved.

but when using validates_length_of, and :maximum, if the value of the field is blank, rails throws an activerecord error "field is too long".

the only way to get around it is to also specify

:allow_nil => true, :allow_blank => true

Which, to me, shouldn't be necessary.

The strange thing is that the test in active record does not produce this problem. I would be happy to look into it if this is a known problem still.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Tags

Referenced by

Pages