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.
23 lines
704 B
JavaScript
23 lines
704 B
JavaScript
"use strict";
|
|
|
|
const validationResult = require("./");
|
|
const ValidationError = require("@validatem/error");
|
|
const { validateValue } = require("@validatem/core");
|
|
|
|
function nonsenseValidator(value) {
|
|
return validationResult({
|
|
errors: [
|
|
new ValidationError("Some nonsense"),
|
|
new ValidationError("Some more nonsense"),
|
|
],
|
|
newValue: value * 2 /* This will currently get lost into the void, because there are validation errors - a future version of Validatem may expose this "partial result", though */
|
|
});
|
|
}
|
|
|
|
let result = validateValue(21, nonsenseValidator);
|
|
/*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At (root): Some nonsense
|
|
- At (root): Some more nonsense
|
|
*/
|