forked from validatem/either
18 lines
564 B
JavaScript
18 lines
564 B
JavaScript
"use strict";
|
|
|
|
const { validateValue } = require("@validatem/core");
|
|
const isNumber = require("@validatem/is-number");
|
|
const isString = require("@validatem/is-string");
|
|
const either = require("./");
|
|
|
|
let rule = either([ isNumber, isString ]);
|
|
|
|
console.log(validateValue("hello world", [ rule ])); // hello world
|
|
|
|
console.log(validateValue(42, [ rule ])); // 42
|
|
|
|
console.log(validateValue(true, [ rule ])); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At (root): Must satisfy at least one of: "Must be a number", "Must be a string"
|
|
*/
|