diff --git a/.benchmark/benchmark.svg b/.benchmark/benchmark.svg index a22842e..f9ff41e 100644 --- a/.benchmark/benchmark.svg +++ b/.benchmark/benchmark.svg @@ -35,10 +35,10 @@ o 1 . - 2 - 8 + 3 + 1 . - 1 + 3 ( a a @@ -295,10 +295,10 @@ c t 4 - 6 - 3 + 5 + 4 . - 3 + 9 8 n s @@ -309,43 +309,44 @@ r ( 4 - 5 - 6 + 3 + 8 . - 2 - 1 - n - s - - 4 - 9 - 7 - . - 4 + 9 + n + s + + 4 + 6 + 8 + . + 3 + 2 n s ) 4 - 6 - 2 + 5 + 7 . - 5 + 0 3 n s 4 - 9 - 7 + 6 + 6 . - 1 - 1 + 3 + 9 n s - 4 - 9 - 7 - . - 4 + 4 + 6 + 8 + . + 3 + 2 n s S @@ -380,10 +381,10 @@ c t 1 - 3 + 5 . - 2 - 7 + 3 + 2 µ s / @@ -391,43 +392,41 @@ t e r - ( - 1 - 2 - . - 3 - 8 - µ - s - - 2 - 4 - 3 + ( + 1 + 2 + . + 6 + 7 + µ + s + + 1 . - 0 - 4 - µ + 3 + 3 + m s ) 1 - 2 + 3 . - 8 - 3 + 9 + 2 µ s - 1 - 7 + 2 + 4 . - 3 - 3 + 1 + 7 µ s - 2 + 3 0 . 3 - 3 + 8 µ s Z @@ -439,10 +438,11 @@ e c t - 9 - 5 - . - 5 + 9 + 4 + . + 4 + 2 µ s / @@ -450,42 +450,45 @@ t e r - ( + ( + 9 + 0 + . 9 - 2 + 6 µ s - 2 - 5 - 4 + 6 + 3 + 8 . - 8 - 3 + 7 + 5 µ s ) 9 - 4 + 3 . - 2 - 9 + 1 + 7 µ s 1 - 6 - 3 + 1 + 5 . - 6 - 7 + 5 + 8 µ s - 1 - 7 - 3 + 2 + 5 + 7 . - 5 - 8 + 2 + 9 µ s A @@ -513,11 +516,11 @@ µ s - 4 - 6 + 5 + 3 . - 2 - 9 + 3 + 8 µ s ) @@ -571,7 +574,7 @@ 2 . 3 - 3 + 1 m s / @@ -587,29 +590,29 @@ m s - 5 + 7 . - 0 - 8 + 2 + 9 m s ) 2 . 3 - 5 + 1 m s 3 . - 5 - 7 + 1 + 5 m s 4 . - 2 - 8 + 1 + 6 m s T @@ -625,12 +628,11 @@ e c t - 7 - 5 - 0 - . - 4 - 9 + 7 + 3 + 4 + . + 6 n s / @@ -640,44 +642,45 @@ r ( 7 - 3 - 7 + 2 + 3 . - 5 - 4 + 7 + 1 n s 8 - 5 - 5 + 8 + 1 . - 1 - 2 + 4 + 5 n s ) - 7 - 5 - 7 - . - 1 + 7 + 4 + 0 + . + 1 + 6 n s 8 - 5 - 5 + 8 + 1 . - 1 - 2 + 4 + 5 n s 8 - 5 - 5 + 8 + 1 . - 1 - 2 + 4 + 5 n s T @@ -714,9 +717,9 @@ c t 2 - 2 + 3 . - 9 + 7 2 µ s @@ -725,43 +728,41 @@ t e r - ( - 2 - 1 - . - 5 - 8 - µ - s - - 2 - 8 - 7 + ( + 2 + 2 + . + 1 + 2 + µ + s + + 2 . - 0 + 1 4 - µ + m s ) 2 2 . - 4 - 6 + 9 + 2 µ s 3 - 1 + 7 . - 7 - 9 + 5 + 4 µ s - 3 - 5 + 4 + 2 . - 1 - 2 + 5 + 4 µ s s @@ -785,7 +786,7 @@ 1 . 6 - 2 + 1 x f a @@ -812,8 +813,8 @@ t 6 . - 8 - 4 + 9 + 6 x f a @@ -834,11 +835,11 @@ e c t - 2 - 8 + 3 + 3 . 6 - 4 + 8 x f a @@ -881,11 +882,11 @@ e c t - 4 - 9 + 5 + 2 . - 4 - 6 + 1 + 2 x f a @@ -932,10 +933,10 @@ t 2 0 - 6 + 7 . - 0 - 9 + 5 + 1 x f a @@ -958,11 +959,11 @@ t 5 0 - 2 - 4 + 8 + 1 . - 1 - 1 + 3 + 4 x f a diff --git a/.benchmark/stubs/validate_safen.ts b/.benchmark/stubs/validate_safen.ts index 8fc5371..8165374 100644 --- a/.benchmark/stubs/validate_safen.ts +++ b/.benchmark/stubs/validate_safen.ts @@ -1,4 +1,4 @@ -import { array, createValidate, decorate, email, or } from "../../mod.ts"; +import { v } from "../../mod.ts"; const DateType = { timestamp: Number, @@ -6,35 +6,35 @@ const DateType = { }; const CommentType = { - id: or([Number, String]), + id: v.union([Number, String]), contents: String, createdAt: DateType, }; const ArticleType = { - id: or([Number, String]), + id: v.union([Number, String]), title: String, content: String, - comments: array(CommentType), + comments: v.array(CommentType), updatedAt: DateType, createdAt: DateType, }; const UserType = { - id: or([Number, String]), - email: decorate(String, email()), + id: v.union([Number, String]), + email: v.decorate(String, (d) => d.email()), name: String, - articles: array(ArticleType), - comments: array(CommentType), + articles: v.array(ArticleType), + comments: v.array(CommentType), location: String, createdAt: DateType, }; -const v = createValidate(UserType); +const validate = v(UserType); export function isUser(user: unknown) { - return v(user); + return validate(user); } export function generateAndIsUser(user: unknown) { - return createValidate(UserType)(user); + return v(UserType)(user); }