475 questions
0
votes
0
answers
6
views
express-validator in node multipart/form-data
I tried sending in postman a form-data with 2 fields, userProData with the Json data of the user, and imageProfile as a file.
I cant find how to send in a single request both body json with user data ...
1
vote
2
answers
136
views
How to apply validator in the Express JS routes based on request header condition
I am passing a token in the request header and based on that I want to change a middleware parameter in the Express JS route.
The current route code:
this.router.post(
"/",
...
0
votes
1
answer
13
views
Dynamic schema selection in express-validator
How can I use the checkSchema function if the schema should be dependent on the body?
For example, if the Type is "A" then SomeData has to be provided in the body but if Type is anything ...
0
votes
1
answer
39
views
I'm trying to use express-validators in a function
Everyone says to use an array but I want to see how to would do it in a function.
I have something like this
const checkPasswordConfirm = () => {
body('password-confirm').custom((value, { req })...
-1
votes
1
answer
39
views
check if any other users have the same email in express-validator
User wants to update their email, i have to check if any other users have it, if so then i return a message saying the email is already in use, i have to check all users but not the user who want to ...
0
votes
0
answers
24
views
Express js route named 'search' having weird behavior
This should work properly as the coide is correct.
the output should be - json on my browser window when the write the adress and load.
But i am seeing Searching for undefined written on my browser ...
0
votes
1
answer
33
views
express-validator use custom validator in validation schema
I'm trying to use custom validator in my validation schema as an object that takes a function but it's not working, it returns back with an error that says: this.validator is not a function but not ...
0
votes
0
answers
39
views
How can I mock up the express-validator withDefaults function using jest?
I am trying to unit test my validation segment which uses express-validator.
This is the code I'm trying to test:
const errorMsgs = require('../lib/error-messages');
const validationResults = ...
0
votes
0
answers
37
views
express-validator Integer or null
I need to do simple validation and allow only Integer values or null. I'm using express-validator 7.2.0 and I'm having a hard time implementing it...
here is my validation middleware:
check('contactID'...
1
vote
1
answer
75
views
How to ignore single quotes in the validator.js isAlphanumeric function
I am trying to validate a string using express validator, specifically with the function isAlphanumeric, but I would like to add space, dash, and single quote as characters to accept.
Here is my code:
...
0
votes
0
answers
27
views
Express validation - delegate code in separate file
How can I call the endpoint defined in another file from this router ?
this im my router.js file:
const express = require('express');
const { body, validationResult } = require('express-validator');
...
1
vote
0
answers
25
views
Why oject property express-validator changed
Property Object change when I used in Array
I had object property types validationChain Object Validator. And I have two array use this obj Two array. I want to know that, why property of this obj had ...
0
votes
1
answer
30
views
Validation Rules for Non-Empty Strings with express-validator Not Working as Expected
ValidationChain Express-validator not working when use obj config
Anyone can help me for this problem. I have two this property. "Status" not working when my req.body.status="", ...
0
votes
4
answers
85
views
Not capable of checking a falsy value at the validation middleware
I've found a weird behavior when trying to check for a falsy value. I guess it is related to the parser across the HTTP. All values inserted (eg http://www.localhost:3000/knex/0) are converted into ...
1
vote
2
answers
120
views
express-validator rejects valid input
I have tried a lot to find the problem, but nothing worked. Here the details, including my errors (at the end). I am just putting the relevant code here. I use express-validator 7.1.0
I am trying to ...