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.
19 lines
526 B
JavaScript
19 lines
526 B
JavaScript
"use strict";
|
|
|
|
const arrayOf = require("./");
|
|
const { validateValue } = require("@validatem/core");
|
|
const isString = require("@validatem/is-string");
|
|
|
|
let validator = arrayOf(isString);
|
|
|
|
let arrayA = ["hello world", "foo", "bar", "baz"];
|
|
|
|
console.log(validateValue(arrayA, validator)); // [ 'hello world', 'foo', 'bar', 'baz' ]
|
|
|
|
let arrayB = ["hello world", "foo", 42, "bar"];
|
|
|
|
console.log(validateValue(arrayB, validator)); /*
|
|
AggregrateValidationError: One or more validation errors occurred:
|
|
- At 2: Must be a string
|
|
*/
|