You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
core/src/api/validation-method.js

18 lines
392 B
JavaScript

"use strict";
const aggregrateErrors = require("../aggregrate-errors");
module.exports = function createValidationMethod(validationFunction) {
return function (... args) {
let { errors, newValue } = validationFunction(... args);
let aggregratedError = aggregrateErrors(errors);
if (aggregratedError != null) {
throw aggregratedError;
} else {
return newValue;
}
};
};