Create a new ValidationChain.
Name of the parameter to validate
Location of the parameter in request
Default error message when validation fails.
Is this parameter optional?
Location of the given parameter.
Validations and sanitations to be executed.
Parameter to be validated.
Remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. blacklist(input, '\[\]').
Characters to blacklist
Build the validation chain. This method has to be called at the end of each validation.
router.post(
'/auth/login',
body('username').equals('user').build(),
body('password').equals('pass').build(),
handler
);
Run the validations and return the results.
The context
Check if the request property contains the given seed.
Custom async validation function to execute. The function must throw when the validation fails.
The validation function
Check if the request property equals the given comparison.
Replace <, >, &, ', ' and / with HTML entities.
Get original input as it is from the request body.
The context
Get parameter from object.
Object to look the property from
Check if the string is a date that's after the specified date (defaults to now).
The date (defaults to now)
Check if the string contains only letters. Locale defaults to en-US.
The locale
Check if the string contains only letters and numbers. Locale defaults to en-US.
The locale
Check if the string contains ASCII characters only.
Check if the string is base64 encoded.
Check if the string is a date that's before the given date, which defaults to now.
The date (defaults to now)
Check if the parameter is a boolean value.
Check if the strin's length (in UTF-8 bytes) falls in range.
The range
Check if the string is a credit card.
Check if the string is a valid currency amount.
The options
Check if the string is a data uri format.
Check if the string represents a decimal number.
The options
Check if the string is a number divisible by given number.
The division number
Check if the parameter is an email.
Check if the parameter is a zero length string.
Check if the string is fully qualified domain name.
The options
Check if the parameter is a float.
Check if the string contains any full-width chars.
Check if the string contains any half-width chars.
Check if the parameter is an algorithm.
The algorithm
Check if the string is a hexadecimal color.
Check if the string is a hexadecimal number.
Check if the string is an IP (ver 4 or 6).
Check if the string is an IP range (ver 4 only).
Check if the string is an ISBN.
The version
Check if the string is an ISIN.
Check if the string is a valid ISO 3166-1 alpha-2 officially assigned country code.
Check if the string is a valid ISO 3166-1 alpha-3 officially assigned country code.
Check if the string is valid ISO8601 date.
Check if the string is a ISRC.
Check if the string is an ISSN.
The options
Check if the parameter is some of the allowed values.
Options containing at least values
property with allowed values
Check if the parameter is an integer.
Check if the parameter is a valid JSON. Uses
JSON.parse
.
Check if the parameter is a valid JWT token.
Check if the parameter is a latitude-lognitude coordinate
in the format lat,long
or lat, long
.
Check if the string is in given length.
Min and max length
Check if the paramter contains only lowercase characters.
Check if the parameter is a MAC address.
Check if the string is a MD5 hash.
Check if the string is a valid MIME type format.
Check if the string is a mobile phone number.
The locale, defaults to any
Check if the parameter is a valid MongoDB ObjectId.
Check if the string contains one or more multibyte chars.
Check if the parameter contains only numbers.
Check if the parameter is a valid port number.
Check if the string is a postal code.
The locale to use
Check if the string is valid RFC3339 date.
Check if the string contains any surrogate pairs chars.
Check if the string is an URL.
Possible options
Check if the parameter is valid UUID (v3, v4 or v5).
Check if the parameter contains only uppercase characters.
Check if the string contains a mixture of full and half-width chars.
Checks characters if they appear in the whitelist.
The characters
Trim characters from the left-side of the input.
The characters to trim
Check if the parameter matches given regular expression.
The regular expression
Normalize email address.
The options
Set this property as optional.
Trim characters from the right-side of the input.
The characters to trim
Sanitize the given input value with given sanitation definition.
The input as string
Remove characters with a numerical value < 32 and 127, mostly control characters. If keep_new_lines is true, newline characters are preserved (\n and \r, hex 0xA and 0xD). Unicode-safe in JavaScript.
convert the input string to a boolean. Everything except for '0', 'false' and '' returns true. In strict mode only '1' and 'true' return true.
Convert the input string to a date.
Convert the input string to a float.
Convert the input string to an integer, or NaN if the input is not an integer.
Trim characters (whitespace by default) from both sides of the input.
The characters to trim
Replaces HTML encoded entities with <, >, &, ", ' and /.
Remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. whitelist(input, '\[\]').
Characters to whitelist
Pass a custom message to the validation.
Custom message
Generated using TypeDoc
The validation chain object.