Skip to content
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

Problem in checkSchema example #748

Closed
stelasido opened this issue Jul 27, 2019 · 7 comments
Closed

Problem in checkSchema example #748

stelasido opened this issue Jul 27, 2019 · 7 comments

Comments

@stelasido
Copy link

Hi, I am following the example from here: https://express-validator.github.io/docs/schema-validation.html . It is the exact same example, but when I run the app, I am getting a warning in the console:

express-validator: a validator/sanitizer with name isUpperCase does not exist

When I make a request to this route, with invalid data, I am getting this error:

TypeError: chars.replace is not a function
at Sanitization.rtrim [as sanitizer] (\node_modules\validator\lib\rtrim.js:15:53)
at Sanitization. (\node_modules\express-validator\src\context-items\sanitization.js:24:24)
at Generator.next ()
at\node_modules\express-validator\src\context-items\sanitization.js:7:71
at new Promise ()
at __awaiter (\node_modules\express-validator\src\context-items\sanitization.js:3:12)
at Sanitization.run (\node_modules\express-validator\src\context-items\sanitization.js:20:16)
at ContextRunnerImpl. (\node_modules\express-validator\src\chain\context-runner-impl.js:31:43)
at Generator.next ()
at \node_modules\express-validator\src\chain\context-runner-impl.js:7:71

@stelasido
Copy link
Author

It doesn't matter, if I send or no the username with the request.

@gustavohenke gustavohenke changed the title Doesn't validate. Problem in checkSchema example Jul 28, 2019
gustavohenke added a commit that referenced this issue Jul 28, 2019
@gustavohenke
Copy link
Member

Hello!
isUpperCase indeed doesn't exist -- the right validator is isUppercase. I've fixed that and pushed a fix to the docs.

Now on to the TypeError: chars.replace is not a function, this is a problem I couldn't replicate. Are you using which version of express-validator?

@stelasido
Copy link
Author

Hi, I am using ^6.1.1. Is there a list of the validators, because I can't guess what I need ?
For the example, I am trying with required, isRequired, but it says express-validator: a validator/sanitizer with name isRequired does not exist.

@sobiodarlington
Copy link

Hi, I am using ^6.1.1. Is there a list of the validators, because I can't guess what I need ?
For the example, I am trying with required, isRequired, but it says express-validator: a validator/sanitizer with name isRequired does not exist.

Check this file for validators
https://github.com/express-validator/express-validator/blob/master/src/chain/validators.ts

Check this file for sanitizers
https://github.com/express-validator/express-validator/blob/master/src/chain/sanitizers.ts

@gustavohenke
Copy link
Member

Also on the docs: https://express-validator.github.io/docs/validation-chain-api.html#standard-validators

@souravray
Copy link

checkSchema({
    parama_name: {
        trim: {
           options: [[" ", "-"]],
        },
    },
 })

Giving me following exception-

chars.replace is not a function

@fedeci
Copy link
Member

fedeci commented Feb 1, 2021

@souravray
This should work:

checkSchema({
    parama_name: {
        trim: {
           options: " -",
        },
    },
 })

@fedeci fedeci closed this as completed Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants