-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type string: alpha and optional option combinations #256
Comments
It's expected, empty string is not a valid |
yes, but I have an |
|
it will be great if empty string also consider as null and undefined for |
You can add a preValidation middleware to delete these keys from object. it's more safe for the validator to be strict |
WHAT?
When I define alpha parameter in the optional field, the validator throws error.
EXAMPLE:
Here is an example how I defined rule for name field.
name: { type: 'string', optional: true, alpha: true, trimLeft: true },
the validator throws error
field must be an alphabetic string
. If I removealpha
then validation on empty field works.EXPECTING:
When
optional
is set thenalpha
will not validate on empty string.VERSION:
latest: 1.11.1
nodejs: 14
The text was updated successfully, but these errors were encountered: