Problem
When a custom validator returns false nothing seems to happen. Validation does not fail and processing continues as if all input were valid.
Expected Behavior
Validation should fail and, depending upon configuration, either raise an error or send a response indicating the request param value was not valid.
Steps to Reproduce
You can simply use the custom validator example from the README:
const params = req.validate({
'role': { validator: (val) => { return /^(user|admin|role)$/.test(val); }}
});
Then issue a request with a role param value of 'notvalid', or any other string not in the allowed regex.
Affected Version
I'm using v2.7.1. I haven't tested other versions.
Problem
When a custom validator returns false nothing seems to happen. Validation does not fail and processing continues as if all input were valid.
Expected Behavior
Validation should fail and, depending upon configuration, either raise an error or send a response indicating the request param value was not valid.
Steps to Reproduce
You can simply use the custom validator example from the README:
Then issue a request with a role param value of 'notvalid', or any other string not in the allowed regex.
Affected Version
I'm using v2.7.1. I haven't tested other versions.