Closed valichek closed 8 years ago
The isNotEmpty (or the inverse: canBeEmpty) is evaluated before any other rule. However we do trim strings before evaluating if they are an 'empty' value, so your ' ' is considered empty and thus valid, until you type a non-space char and it starts evaluating the other rules (containsNoSpaces).
Not sure how we can change this without breaking the api,
ensure('firstname').isNotEmpty().hasMaxLength(3)
This would consider ' ' to be valid, although it's really not what you want the user to be able to enter as a first name.
We could add overloads isNotEmptyOrWhitespace and canBeEmptyOrWhitespace...
OTOH I can assume many people will prefer 'isNotEmpty()' to check for isNotEmptyOrWhitespace by default.
Thoughts?
Thanks for submitting this / commenting on this. At this time we are closing this because we have completely re-written and are deprecating the previous feature set. If you feel this should be re-opened please feel free to review this blog post and submit either again on this repository, or on the new validatejs bridge repository
Thanks again!
When I start with entering spaces it validates to true until I enter "not space" char.