Middleware
A Validation
object created with the Validation.profile()
method can be used as a middleware function on the server side.
Syntax
Parameters
Please refer to Express
documentation.
Return value
None (undefined
).
Exceptions
If invoked without having created a validation profile, throws the corresponding error. Also see “Exceptions” of the Validation().validate()
method.
Description
When invoked on the server side, runs a data mapper function and the Validation().validate()
method. Assigns a validation result to the incoming request object which can be accessed in the next executed middleware. Only validations created with the Validation.profile()
method can be used as middleware functions.
Using a Validation
object as a middleware function is intended to reduce boilerplate code.