diff --git a/Validator.test.ts b/Validator.test.ts index 1208bee..06989c6 100644 --- a/Validator.test.ts +++ b/Validator.test.ts @@ -102,39 +102,37 @@ Deno.test("validate schema (no match)", async () => { } }); - - - - - - Deno.test("validate doConversion (match)", async () => { const values: [any, Validatable, any][] = [ [ 1, isNumber(), - 1 + 1, ], [ "2", isNumber(), - 2 + 2, ], [ "03", isNumber(), - 3 + 3, ], [ { foo: 3, bar: { baz: "4", other: "val" } }, { foo: isNumber(), bar: { baz: isNumber() } }, - { foo: 3, bar: { baz: 4 } } + { foo: 3, bar: { baz: 4 } }, ], ]; for (const [value, constraints, conv] of values) { const valueBefore = JSON.stringify(value); const converted: any = {}; - assertEquals(await validate(value, constraints, {doConversion: true, converted}), [], String(value)); + assertEquals( + await validate(value, constraints, { doConversion: true, converted }), + [], + String(value), + ); const valueAfter = JSON.stringify(value); assertEquals(valueAfter, valueBefore); assertEquals(converted.hasOwnProperty("output"), true); @@ -156,10 +154,14 @@ Deno.test("validate doConversion (no match)", async () => { for (const [value, constraints] of values) { const valueBefore = JSON.stringify(value); const converted: any = {}; - assertNotEquals(await validate(value, constraints, {doConversion: true, converted}), [], String(value)); + assertNotEquals( + await validate(value, constraints, { doConversion: true, converted }), + [], + String(value), + ); const valueAfter = JSON.stringify(value); assertEquals(valueAfter, valueBefore); assertEquals(converted.hasOwnProperty("output"), true); assertEquals(converted?.output, value); } -}); \ No newline at end of file +}); diff --git a/mod.ts b/mod.ts index 7d7704d..b01ee8f 100644 --- a/mod.ts +++ b/mod.ts @@ -6,8 +6,18 @@ export { Validatable, ArraySymbol, } from "./Validator.ts"; -export { isString, isUrl, isEmail, fulfillsRegex } from "./validators/string.ts"; -export { isNumber, isInteger, isInRange, hasParity } from "./validators/number.ts"; +export { + isString, + isUrl, + isEmail, + fulfillsRegex, +} from "./validators/string.ts"; +export { + isNumber, + isInteger, + isInRange, + hasParity, +} from "./validators/number.ts"; export { isArray } from "./validators/array.ts"; export { or } from "./validators/logic.ts"; export { isRequired, isDefined, isNotEmpty } from "./validators/empty.ts"; diff --git a/t.ts b/t.ts deleted file mode 100644 index 9525a6c..0000000 --- a/t.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { - ValidationError, validate, - isBoolean -} from "./mod.ts"; - -const converted: any = {}; -const errors: ValidationError[] = await validate("foobar", isBoolean(), { doConversion: true, converted }); -console.log(errors); -// [ { type: "isBoolean", args: {}, message: "This value has to be a boolean." } ] -console.log(converted); -// { output: "foobar" } \ No newline at end of file