sfcode
An Online Competing and Development Environment
|
ensure(validationDatum1[, ...validationDatumN[, options]])
Provides a complete cumulated input validation for an API endpoint. Validates multiple input arguments and consolidates eventual errors into one.
For each argument to be validated a validationDatum
of following stucture should be defined:
argumentName
- Name of validated argument (used for meaningful error messaging)inputValue
- An argument value as passed to functionensureFunction
- An ensureX
function with which argument should be validated (e.g. if we're after string, then we need string/ensure)options
- Optional, extra options to be passed to ensureX
functionEventual options be passed to underlying ensureX
functions. If custom error constructor is passed with an Error
option, then cumulated error is created with this constructor.