Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

allow_blank => false can be ineffective on validates_length_of

#5862

(2.3.10)

I expected

    validates_length_of :foo, :maximum => 10, :allow_blank => false

to prohibit empty strings, but it doesn't. If this is the desired behavior it would be helpful for the docs to make it clear (for instance, "Note: setting :allow_blank to false will not cause this validation to fail if it would otherwise pass.")

Reported by Jacob Williams · October 25th, 2010 @ 05:49 PM

State: wontfix
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • State changed from new to wontfix
    • Importance changed from to Low

    The documentation explicitly states that the validation will be skipped if the value is blank so it follows that the validation will not be skipped if the value is not blank. Feel free to check out the docrails project if you think the documentation could be improved.

    October 26th, 2010 @ 10:43 AM