more validators

This commit is contained in:
Sebastian Seedorf
2020-05-26 16:52:26 +02:00
parent 7367af7fe4
commit 9fa06685ba
13 changed files with 340 additions and 14 deletions

38
validators/array.test.ts Normal file
View File

@@ -0,0 +1,38 @@
import { isArray } from "./array.ts";
import { validate } from "../mod.ts";
import {
assertEquals,
assertNotEquals,
} from "https://deno.land/std@0.53.0/testing/asserts.ts";
Deno.test("isArray (match)", async () => {
const values = [
undefined,
null,
[],
["foo"],
];
for (const value of values) {
assertEquals(await validate(value, isArray), []);
}
});
Deno.test("isArray (no match)", async () => {
const values = [
0,
1,
false,
true,
"",
"foo",
new String(),
new String("bar"),
() => {},
function named() {},
new Object(),
Symbol(),
];
for (const value of values) {
assertNotEquals(await validate(value, isArray), []);
}
});