#1368 ✓not-applicable
Kevin Watt

Text with :length validations >0 still allow null

Reported by Kevin Watt | July 17th, 2010 @ 01:39 AM

property :reason, Text, :length => 20..9999

b = Ban.new
b.valid? => true
b.reason = 'a' => 'reason must be between 20 and 9999 characters long'
b.valid? => true

Perhaps the way it works for String is meant to be different from Text.

Adding :required => true works as expected, it was just my impression that it was implicit with a length requirement > 0

Sorry to be adding so many bugs; perhaps I'll feel comfortable with the source soon to jump in and start making patch suggestions if others mark the bugs as accepted/etc. Thanks for a great project!

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) July 27th, 2010 @ 11:19 PM

    • State changed from “new” to “not-applicable”

    The :length constraint is independent from the :required constraint. Specifying the length does not automatically make a property required.

    There are many cases where you might specify the constraints of a property that is otherwise optional.

    No worries about submitting lots of bugs. Some of them may be valid, while others may not be but point us towards things we need to document better in the future.

  • Kevin Watt

    Kevin Watt July 27th, 2010 @ 11:33 PM

    Ah. My impression was that it was required because the docs here say 'won't allow null'. Are they wrong, or is null different from not required?

    :length => (1..20) # cant be null :length => (0..20) # can be null

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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