-
Notifications
You must be signed in to change notification settings - Fork 4
Automated validators
From version 2.0, it's possible to add automatic validators/reviewers which are triggered after every applicant submission. While the applicant doesn't achieve these validators, its submission cannot be reviewed by the supervisor.
If you want to add a validator to any question, you just have to select it in the process editor. Be careful by defining the options - you can copy paste the example and edit it.
A validator is mainly a JavaScript function which takes two arguments: the answer and some parameters (a JavaScript object).
- Create a new file named
<myAwesomeValidator>.jsinto the folderbackend/validators/automated/ - Create a function
validatorwhich takes two arguments.
_For example: _
function validator(value, { minWords }) {
}This function should throw an explicit error message if it fails. This error message is sent to the applicant by email.
For example
throw `Your answer contains only ${nbWords} words and ${minWords} are expected`;- Export your function
module.exports.validator = validator;-
Add a new entry to the
validatorsobject inindex.jswith the function, a label, a description, and an option example. The key should beMY_AWESOME_VALIDATOR -
Add some tests in
backend/test/automated_validators.js