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