jtla.blogg.se

Expressvalidator
Expressvalidator











expressvalidator

validationResult(req)Įxtracts the validation errors from a request and makes it available in the form of a validation result object. While the execution within a chain still respects the rule defined in the check() function. The execution of those validation chains are made in parallel, Using the given message, and the errors of each chain will be made available under a key nestedErrors. If none of the given chains passes, an error will be pushed to the _error pseudo-field, Defaults to Invalid value(s).Ĭreates a middleware instance that will ensure at least one of the given chains passes the validation. message (optional): an error message to use when all chains failed.validationChains: an array of validation chains created with check() or any of its variations.Same as check(fields), but only checking req.query. Same as check(fields), but only checking req.params. Same as check(fields), but only checking req.headers. Same as check(fields), but only checking req.cookies. Same as check(fields), but only checking req.body. This means that if the chain targets more than one field, those will run in parallel, but each of their validators are serial. The validators will always be executed serially for the same field. If any of the fields are present in more than one location, then all instances of that field value must pass the validation. They may be located in any of the following request objects: Defaults to Invalid value.Ĭreates a validation chain for one or more fields. message (optional): an error message to use when failed validators don't specify a message.field: a string or an array of strings of field names to validate against.These methods are all available via require('express-validator/check').













Expressvalidator