Skip to content

Custom Validator Support Not Working #5

@scottescue

Description

@scottescue

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions