#15 needs-git-fork
Karl Smith

Test fails with :allow_blank and :allow_nil are true

Reported by Karl Smith | February 7th, 2008 @ 01:51 PM

In model:

validates_length_of :middle_initial, :is => 1, :allow_blank => true

Will fail test with:

should_ensure_length_in_range :middle_initial, (1..1)

should_ensure_length_in_range :middle_initial, (0..1)

Reason:

should_ensure_length_in_range will test the attribute with a zero length string, which is valid when :allow_blank is set to true. And skips lengths less than zero, as in the second case.

Comments and changes to this ticket

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

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