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.

18 lines
564 B
JavaScript

5 years ago
"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"
*/