added number

This commit is contained in:
Sebastian Seedorf
2020-05-26 00:42:16 +02:00
parent 218e596ede
commit c59e4a6a50
5 changed files with 101 additions and 4 deletions

View File

@@ -7,6 +7,8 @@ import {
Validatable,
ArraySymbol,
isString,
isNumber,
isInteger,
} from "./mod.ts";
Deno.test("validate schema (match)", async () => {
@@ -14,7 +16,7 @@ Deno.test("validate schema (match)", async () => {
["string", isString],
["string", [isString]],
[["arr", "ay"], { [ArraySymbol]: isString }],
[{ foo: "bar", lorem: "ipsum" }, { foo: isString, lorem: [isString] }],
[{ foo: 3.1415, lorem: "ipsum" }, { foo: isNumber, lorem: [isString] }],
];
for (const [value, constraints] of values) {
assertEquals([], await validate(value, constraints));
@@ -26,7 +28,7 @@ Deno.test("validate schema (no match)", async () => {
[6, isString],
[false, [isString]],
[["arr", ["ay"]], { [ArraySymbol]: isString }],
[{ foo: {}, lorem: "ipsum" }, { foo: isString, lorem: [isString] }],
[{ foo: 3.1415, lorem: "ipsum" }, { foo: isInteger, lorem: [isString] }],
];
for (const [value, constraints] of values) {
assertNotEquals([], await validate(value, constraints));