I have a password field and that validates presence
and length
and both are working fine. But when I submit the form with blank password field, it displays error messages for both validations.
What I want is if the password is blank then length
validator must not checked and display error message for only presence
validator. Length validator will only be checked if password is present.
Along with other validations pass this
:allow_blank => true
For example
validates :password, :presence => true, :length => { :maximum => 20, :allow_blank => true }