more validators
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
isString,
|
||||
isNumber,
|
||||
isInteger,
|
||||
isRequired,
|
||||
} from "./mod.ts";
|
||||
|
||||
Deno.test("validate schema (match)", async () => {
|
||||
@@ -17,6 +18,11 @@ Deno.test("validate schema (match)", async () => {
|
||||
["string", [isString]],
|
||||
[["arr", "ay"], { [ArraySymbol]: isString }],
|
||||
[{ foo: 3.1415, lorem: "ipsum" }, { foo: isNumber, lorem: [isString] }],
|
||||
[{}, { optional: [isString] }],
|
||||
[{ foo: { bar: "" } }, { foo: { bar: [isRequired, isString] } }],
|
||||
[{ foo: { bar: "" } }, { foo: { bar: [isString] } }],
|
||||
[{ foo: {} }, { foo: { bar: [isString] } }],
|
||||
[{}, { foo: { bar: [isString] } }],
|
||||
];
|
||||
for (const [value, constraints] of values) {
|
||||
assertEquals([], await validate(value, constraints));
|
||||
@@ -29,6 +35,10 @@ Deno.test("validate schema (no match)", async () => {
|
||||
[false, [isString]],
|
||||
[["arr", ["ay"]], { [ArraySymbol]: isString }],
|
||||
[{ foo: 3.1415, lorem: "ipsum" }, { foo: isInteger, lorem: [isString] }],
|
||||
[{}, { required: [isRequired, isString] }],
|
||||
[{ foo: { bar: 1 } }, { foo: { bar: [isRequired, isString] } }],
|
||||
[{ foo: {} }, { foo: { bar: [isRequired, isString] } }],
|
||||
[{}, { foo: { bar: [isRequired, isString] } }],
|
||||
];
|
||||
for (const [value, constraints] of values) {
|
||||
assertNotEquals([], await validate(value, constraints));
|
||||
|
||||
Reference in New Issue
Block a user