backbone-forms icon indicating copy to clipboard operation
backbone-forms copied to clipboard

Empty and non-matching field should fail match validation

Open lennym opened this issue 12 years ago • 4 comments

If it is empty, a field with match validation type passes validation even though its value does not match. The field is in a known invalid state and so validation should fail.

lennym avatar Dec 07 '12 15:12 lennym

This was actually an intentional decision, so that you can have fields that aren't required (can be empty) but if a value is submitted then it must match the validator.

You can 'fix' this by just adding a 'required' validator as well as the match validator.

powmedia avatar Dec 12 '12 14:12 powmedia

That's only a "fix" if the field is required. If fields are optional but need to match then it's the very opposite of a fix.

lennym avatar Dec 12 '12 15:12 lennym

Sorry, my mistake - I thought you were referring to a general Regular Expression match

powmedia avatar Dec 12 '12 16:12 powmedia

Yes, I see your point with respect to not validating empty values for certain validators, but I think the match validator in particular should pass iff the field values match.

lennym avatar Dec 12 '12 16:12 lennym