1

With this rule

validates_format_of :numbers, :with => /^[0-9]{15}$/, :message => "error message"

will be the item :numbers valid only with the regex above. But is possible to set, that the item :numbers could be send as an empty or like a 15 digits? I can't find the right combination of validation rules.

1 Answer 1

2

Just add the allow_blank option like:

validates_format_of :numbers, :with => /^[0-9]{15}$/, :allow_blank => true

See docs for further information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.