-
Notifications
You must be signed in to change notification settings - Fork 4
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
Custom Validator Support Not Working #5
Comments
Sorry about the delayed response. I don't know how I missed this message but I will look into this now. Thanks for the bug report. |
For testing purposes I give it true|false but it did not give any response or error. const params = req.validate({
'role': { validator: (val) => { return false; }}
}); Nothing happens. |
Try the sails-hook-req-validate v2.8.0 or later. I updated the function validation feature. const params = req.validate({
'role': (val) => { return false; }
}); |
Thanks John, If I see your comment clearly, we can only add validator. How can I add validator and converter both? |
Ahh.. I see. I originally created this hook for my own project and I don't
use a custom validator and converter together in my projects, so I didn't
think about this use case. but I can understand that it can be useful.
I will update the code once again to re-enable the validator option.
Thank you for your suggestion.
…On Thu, Mar 5, 2020 at 5:00 AM Nasir Mehmood ***@***.***> wrote:
Thanks John,
If I see your comment clearly, we can only add validator. How can I add
validator and converter both?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#5?email_source=notifications&email_token=AADEPTGOQYJVICP6WU7YSCDRF5Z2RA5CNFSM4J3NDYQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN4RMKA#issuecomment-595138088>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADEPTDXA4C6JBU6273RAILRF5Z2RANCNFSM4J3NDYQQ>
.
|
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.
The text was updated successfully, but these errors were encountered: