@oxog/vld 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -1
- package/LICENSE +20 -20
- package/README.md +101 -37
- package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
- package/dist/chunks/{index-CETyGkrv.js → index-0R2ntSud.js} +16 -402
- package/dist/chunks/index-BvH403Yy.js +88 -0
- package/dist/chunks/security-B0Pd_vSY.js +35 -0
- package/dist/chunks/string-BJRQod3t.js +530 -0
- package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +83 -0
- package/dist/cjs/chunks/index-BkI37108.cjs +538 -0
- package/dist/cjs/chunks/index-Cc3bjUMX.cjs +91 -0
- package/dist/cjs/chunks/security-Dc3Jh13T.cjs +37 -0
- package/dist/cjs/chunks/string-BKZrc4hs.cjs +533 -0
- package/dist/cjs/cli/bin.cjs +506 -0
- package/dist/cjs/cli/index.cjs +209 -0
- package/dist/cjs/codecs/index.cjs +45 -0
- package/dist/{chunks/date-ODue_rtq.js → cjs/coercion/index.cjs} +185 -103
- package/dist/cjs/compat/emitter.cjs +184 -0
- package/dist/cjs/compat/result.cjs +189 -0
- package/dist/cjs/errors.cjs +6 -213
- package/dist/cjs/index.cjs +1558 -9647
- package/dist/cjs/kernel.cjs +415 -0
- package/dist/cjs/locales/af.cjs +108 -0
- package/dist/cjs/locales/ar.cjs +108 -0
- package/dist/cjs/locales/bn.cjs +108 -0
- package/dist/cjs/locales/da.cjs +108 -0
- package/dist/cjs/locales/de.cjs +108 -0
- package/dist/cjs/locales/en.cjs +108 -0
- package/dist/cjs/locales/es-MX.cjs +107 -0
- package/dist/cjs/locales/es.cjs +96 -0
- package/dist/cjs/locales/fi.cjs +108 -0
- package/dist/cjs/locales/fr.cjs +96 -0
- package/dist/cjs/locales/hi.cjs +108 -0
- package/dist/cjs/locales/id.cjs +108 -0
- package/dist/cjs/locales/index.cjs +41 -2875
- package/dist/cjs/locales/it.cjs +108 -0
- package/dist/cjs/locales/ja.cjs +108 -0
- package/dist/cjs/locales/ko.cjs +108 -0
- package/dist/cjs/locales/lazy.cjs +42 -3023
- package/dist/cjs/locales/nl.cjs +108 -0
- package/dist/cjs/locales/no.cjs +108 -0
- package/dist/cjs/locales/pl.cjs +108 -0
- package/dist/cjs/locales/pt-BR.cjs +108 -0
- package/dist/cjs/locales/pt.cjs +108 -0
- package/dist/cjs/locales/ru.cjs +108 -0
- package/dist/cjs/locales/runtime.cjs +51 -0
- package/dist/cjs/locales/sv.cjs +108 -0
- package/dist/cjs/locales/sw.cjs +108 -0
- package/dist/cjs/locales/th.cjs +108 -0
- package/dist/cjs/locales/tr.cjs +108 -0
- package/dist/cjs/locales/vi.cjs +108 -0
- package/dist/cjs/locales/zh.cjs +108 -0
- package/dist/cjs/mini.cjs +121 -7208
- package/dist/cjs/pigment.cjs +207 -0
- package/dist/cjs/plugins/index.cjs +12 -0
- package/dist/cjs/registry.cjs +37 -0
- package/dist/cjs/v3/index.cjs +425 -0
- package/dist/cjs/v4/core/index.cjs +894 -0
- package/dist/cjs/v4/index.cjs +425 -0
- package/dist/cjs/v4/locales/index.cjs +130 -0
- package/dist/cjs/v4/mini/index.cjs +509 -0
- package/dist/cjs/v4-mini/index.cjs +532 -0
- package/dist/cjs/validators/any.cjs +40 -0
- package/dist/cjs/validators/array.cjs +283 -0
- package/dist/cjs/validators/base.cjs +887 -0
- package/dist/cjs/validators/base64.cjs +73 -0
- package/dist/cjs/validators/bigint.cjs +232 -0
- package/dist/cjs/validators/boolean.cjs +146 -0
- package/dist/cjs/validators/codec.cjs +205 -0
- package/dist/cjs/validators/custom.cjs +71 -0
- package/dist/cjs/validators/date.cjs +278 -0
- package/dist/cjs/validators/discriminated-union.cjs +130 -0
- package/dist/cjs/validators/enum.cjs +154 -0
- package/dist/cjs/validators/file.cjs +130 -0
- package/dist/cjs/validators/function.cjs +63 -0
- package/dist/cjs/validators/hex.cjs +70 -0
- package/dist/cjs/validators/index.cjs +123 -0
- package/dist/cjs/validators/intersection.cjs +120 -0
- package/dist/cjs/validators/json.cjs +70 -0
- package/dist/cjs/validators/lazy.cjs +53 -0
- package/dist/cjs/validators/literal.cjs +64 -0
- package/dist/cjs/validators/map.cjs +218 -0
- package/dist/cjs/validators/nan.cjs +41 -0
- package/dist/cjs/validators/never.cjs +36 -0
- package/dist/cjs/validators/null.cjs +43 -0
- package/dist/cjs/validators/number.cjs +427 -0
- package/dist/cjs/validators/object.cjs +868 -0
- package/dist/cjs/validators/promise.cjs +115 -0
- package/dist/cjs/validators/record.cjs +262 -0
- package/dist/cjs/validators/set.cjs +203 -0
- package/dist/cjs/validators/string-bool.cjs +124 -0
- package/dist/cjs/validators/string-formats.cjs +168 -0
- package/dist/cjs/validators/string.cjs +12 -0
- package/dist/cjs/validators/symbol.cjs +62 -0
- package/dist/cjs/validators/template-literal.cjs +108 -0
- package/dist/cjs/validators/tuple.cjs +187 -0
- package/dist/cjs/validators/uint8array.cjs +106 -0
- package/dist/cjs/validators/undefined.cjs +43 -0
- package/dist/cjs/validators/union.cjs +191 -0
- package/dist/cjs/validators/unknown.cjs +40 -0
- package/dist/cjs/validators/void.cjs +48 -0
- package/dist/cjs/validators/xor.cjs +69 -0
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +407 -0
- package/dist/cli/commands/benchmark.d.ts +1 -2
- package/dist/cli/commands/validate.d.ts +1 -2
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +205 -0
- package/dist/codecs/index.d.ts +21 -4
- package/dist/codecs/index.js +11 -4
- package/dist/coercion/bigint.d.ts +2 -3
- package/dist/coercion/boolean.d.ts +3 -3
- package/dist/coercion/date.d.ts +3 -3
- package/dist/coercion/index.d.ts +5 -6
- package/dist/coercion/index.js +473 -5
- package/dist/coercion/number.d.ts +2 -3
- package/dist/coercion/string.d.ts +2 -3
- package/dist/compat/emitter.d.ts +0 -1
- package/dist/compat/emitter.js +0 -1
- package/dist/compat/index.d.ts +4 -5
- package/dist/compat/result.d.ts +1 -2
- package/dist/compat/result.js +0 -1
- package/dist/errors-core.d.ts +39 -0
- package/dist/errors.d.ts +4 -54
- package/dist/errors.js +4 -68
- package/dist/events.d.ts +3 -4
- package/dist/index.d.ts +1195 -600
- package/dist/index.js +1262 -44
- package/dist/kernel.d.ts +2 -3
- package/dist/kernel.js +10 -6
- package/dist/locales/af.d.ts +1 -2
- package/dist/locales/af.js +0 -1
- package/dist/locales/ar.d.ts +1 -2
- package/dist/locales/ar.js +0 -1
- package/dist/locales/bn.d.ts +1 -2
- package/dist/locales/bn.js +0 -1
- package/dist/locales/da.d.ts +1 -2
- package/dist/locales/da.js +0 -1
- package/dist/locales/de.d.ts +1 -2
- package/dist/locales/de.js +0 -1
- package/dist/locales/en.d.ts +1 -2
- package/dist/locales/en.js +0 -1
- package/dist/locales/es-MX.d.ts +1 -2
- package/dist/locales/es-MX.js +0 -1
- package/dist/locales/es.d.ts +1 -2
- package/dist/locales/es.js +0 -1
- package/dist/locales/fi.d.ts +1 -2
- package/dist/locales/fi.js +0 -1
- package/dist/locales/fr.d.ts +1 -2
- package/dist/locales/fr.js +0 -1
- package/dist/locales/hi.d.ts +1 -2
- package/dist/locales/hi.js +0 -1
- package/dist/locales/id.d.ts +1 -2
- package/dist/locales/id.js +0 -1
- package/dist/locales/index.d.ts +10 -15
- package/dist/locales/index.js +28 -2
- package/dist/locales/it.d.ts +1 -2
- package/dist/locales/it.js +0 -1
- package/dist/locales/ja.d.ts +1 -2
- package/dist/locales/ja.js +0 -1
- package/dist/locales/ko.d.ts +1 -2
- package/dist/locales/ko.js +0 -1
- package/dist/locales/lazy.d.ts +4 -26
- package/dist/locales/lazy.js +12 -55
- package/dist/locales/nl.d.ts +1 -2
- package/dist/locales/nl.js +0 -1
- package/dist/locales/no.d.ts +1 -2
- package/dist/locales/no.js +0 -1
- package/dist/locales/pl.d.ts +1 -2
- package/dist/locales/pl.js +0 -1
- package/dist/locales/pt-BR.d.ts +1 -2
- package/dist/locales/pt-BR.js +0 -1
- package/dist/locales/pt.d.ts +1 -2
- package/dist/locales/pt.js +0 -1
- package/dist/locales/ru.d.ts +1 -2
- package/dist/locales/ru.js +0 -1
- package/dist/locales/runtime.d.ts +10 -0
- package/dist/locales/runtime.js +41 -0
- package/dist/locales/sv.d.ts +1 -2
- package/dist/locales/sv.js +0 -1
- package/dist/locales/sw.d.ts +1 -2
- package/dist/locales/sw.js +0 -1
- package/dist/locales/th.d.ts +1 -2
- package/dist/locales/th.js +0 -1
- package/dist/locales/tr.d.ts +1 -2
- package/dist/locales/tr.js +0 -1
- package/dist/locales/types.d.ts +0 -1
- package/dist/locales/vi.d.ts +1 -2
- package/dist/locales/vi.js +0 -1
- package/dist/locales/zh.d.ts +1 -2
- package/dist/locales/zh.js +0 -1
- package/dist/logger.d.ts +0 -1
- package/dist/mini.d.ts +64 -65
- package/dist/mini.js +31 -7
- package/dist/pigment.d.ts +0 -1
- package/dist/pigment.js +6 -4
- package/dist/plugins/index.d.ts +2 -3
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/types.d.ts +4 -5
- package/dist/registry.d.ts +23 -0
- package/dist/registry.js +34 -0
- package/dist/utils/codec-utils.d.ts +0 -1
- package/dist/utils/deep-merge.d.ts +0 -1
- package/dist/utils/ip-validation.d.ts +0 -1
- package/dist/utils/json-schema.d.ts +77 -0
- package/dist/utils/security.d.ts +2 -6
- package/dist/v3/index.d.ts +2 -0
- package/dist/v3/index.js +46 -0
- package/dist/v4/core/index.d.ts +260 -0
- package/dist/v4/core/index.js +277 -0
- package/dist/v4/index.d.ts +4 -0
- package/dist/v4/index.js +50 -0
- package/dist/v4/locales/index.d.ts +53 -0
- package/dist/v4/locales/index.js +77 -0
- package/dist/v4/mini/index.d.ts +2 -0
- package/dist/v4/mini/index.js +47 -0
- package/dist/v4-mini/index.d.ts +22 -0
- package/dist/v4-mini/index.js +75 -0
- package/dist/validators/any.d.ts +7 -2
- package/dist/validators/any.js +37 -0
- package/dist/validators/array.d.ts +9 -2
- package/dist/validators/array.js +279 -0
- package/dist/validators/base.d.ts +228 -5
- package/dist/validators/base.js +868 -0
- package/dist/validators/base64.d.ts +1 -2
- package/dist/validators/base64.js +68 -0
- package/dist/validators/bigint.d.ts +21 -3
- package/dist/validators/bigint.js +228 -0
- package/dist/validators/boolean.d.ts +13 -4
- package/dist/validators/boolean.js +142 -0
- package/dist/validators/codec.d.ts +9 -2
- package/dist/validators/codec.js +200 -0
- package/dist/validators/custom.d.ts +15 -2
- package/dist/validators/custom.js +67 -0
- package/dist/validators/date.d.ts +19 -3
- package/dist/validators/date.js +274 -0
- package/dist/validators/discriminated-union.d.ts +4 -3
- package/dist/validators/discriminated-union.js +123 -0
- package/dist/validators/enum.d.ts +10 -7
- package/dist/validators/enum.js +150 -0
- package/dist/validators/file.d.ts +7 -2
- package/dist/validators/file.js +125 -0
- package/dist/validators/function.d.ts +11 -5
- package/dist/validators/function.js +58 -0
- package/dist/validators/hex.d.ts +1 -2
- package/dist/validators/hex.js +65 -0
- package/dist/validators/index.d.ts +38 -38
- package/dist/validators/index.js +35 -5
- package/dist/validators/intersection.d.ts +1 -2
- package/dist/validators/intersection.js +116 -0
- package/dist/validators/json.d.ts +1 -2
- package/dist/validators/json.js +66 -0
- package/dist/validators/lazy.d.ts +5 -9
- package/dist/validators/lazy.js +50 -0
- package/dist/validators/literal.d.ts +2 -2
- package/dist/validators/literal.js +60 -0
- package/dist/validators/map.d.ts +15 -2
- package/dist/validators/map.js +214 -0
- package/dist/validators/nan.d.ts +2 -3
- package/dist/validators/nan.js +38 -0
- package/dist/validators/never.d.ts +1 -2
- package/dist/validators/never.js +32 -0
- package/dist/validators/null.d.ts +3 -3
- package/dist/validators/null.js +40 -0
- package/dist/validators/number.d.ts +80 -21
- package/dist/validators/number.js +423 -0
- package/dist/validators/object.d.ts +30 -9
- package/dist/validators/object.js +864 -0
- package/dist/validators/promise.d.ts +58 -0
- package/dist/validators/promise.js +111 -0
- package/dist/validators/record.d.ts +11 -2
- package/dist/validators/record.js +258 -0
- package/dist/validators/set.d.ts +11 -2
- package/dist/validators/set.js +199 -0
- package/dist/validators/string-bool.d.ts +7 -10
- package/dist/validators/string-bool.js +120 -0
- package/dist/validators/string-formats.d.ts +13 -4
- package/dist/validators/string-formats.js +135 -0
- package/dist/validators/string.d.ts +39 -18
- package/dist/validators/string.js +4 -0
- package/dist/validators/symbol.d.ts +8 -3
- package/dist/validators/symbol.js +58 -0
- package/dist/validators/template-literal.d.ts +1 -2
- package/dist/validators/template-literal.js +103 -0
- package/dist/validators/tuple.d.ts +15 -2
- package/dist/validators/tuple.js +183 -0
- package/dist/validators/uint8array.d.ts +3 -4
- package/dist/validators/uint8array.js +101 -0
- package/dist/validators/undefined.d.ts +3 -3
- package/dist/validators/undefined.js +40 -0
- package/dist/validators/union.d.ts +7 -4
- package/dist/validators/union.js +187 -0
- package/dist/validators/unknown.d.ts +7 -2
- package/dist/{chunks/unknown-SLIH1VCf.js → validators/unknown.js} +12 -3
- package/dist/validators/void.d.ts +3 -2
- package/dist/validators/void.js +44 -0
- package/dist/validators/xor.d.ts +2 -3
- package/dist/validators/xor.js +66 -0
- package/package.json +116 -31
- package/dist/chunks/bigint-DgsCr2dC.js +0 -1709
- package/dist/chunks/bigint-DgsCr2dC.js.map +0 -1
- package/dist/chunks/date-ODue_rtq.js.map +0 -1
- package/dist/chunks/index-BZqWZvVe.js +0 -426
- package/dist/chunks/index-BZqWZvVe.js.map +0 -1
- package/dist/chunks/index-CETyGkrv.js.map +0 -1
- package/dist/chunks/json-o20GFhTh.js +0 -2021
- package/dist/chunks/json-o20GFhTh.js.map +0 -1
- package/dist/chunks/unknown-SLIH1VCf.js.map +0 -1
- package/dist/cjs/errors.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/locales/index.cjs.map +0 -1
- package/dist/cjs/locales/lazy.cjs.map +0 -1
- package/dist/cjs/mini.cjs.map +0 -1
- package/dist/cli/bin.d.ts.map +0 -1
- package/dist/cli/commands/benchmark.d.ts.map +0 -1
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/codecs/index.d.ts.map +0 -1
- package/dist/codecs/index.js.map +0 -1
- package/dist/coercion/bigint.d.ts.map +0 -1
- package/dist/coercion/boolean.d.ts.map +0 -1
- package/dist/coercion/date.d.ts.map +0 -1
- package/dist/coercion/index.d.ts.map +0 -1
- package/dist/coercion/index.js.map +0 -1
- package/dist/coercion/number.d.ts.map +0 -1
- package/dist/coercion/string.d.ts.map +0 -1
- package/dist/compat/emitter.d.ts.map +0 -1
- package/dist/compat/emitter.js.map +0 -1
- package/dist/compat/index.d.ts.map +0 -1
- package/dist/compat/result.d.ts.map +0 -1
- package/dist/compat/result.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/locales/af.d.ts.map +0 -1
- package/dist/locales/af.js.map +0 -1
- package/dist/locales/ar.d.ts.map +0 -1
- package/dist/locales/ar.js.map +0 -1
- package/dist/locales/backup-en.d.ts +0 -3
- package/dist/locales/backup-en.d.ts.map +0 -1
- package/dist/locales/bn.d.ts.map +0 -1
- package/dist/locales/bn.js.map +0 -1
- package/dist/locales/da.d.ts.map +0 -1
- package/dist/locales/da.js.map +0 -1
- package/dist/locales/de.d.ts.map +0 -1
- package/dist/locales/de.js.map +0 -1
- package/dist/locales/en.d.ts.map +0 -1
- package/dist/locales/en.js.map +0 -1
- package/dist/locales/es-MX.d.ts.map +0 -1
- package/dist/locales/es-MX.js.map +0 -1
- package/dist/locales/es.d.ts.map +0 -1
- package/dist/locales/es.js.map +0 -1
- package/dist/locales/fi.d.ts.map +0 -1
- package/dist/locales/fi.js.map +0 -1
- package/dist/locales/fr.d.ts.map +0 -1
- package/dist/locales/fr.js.map +0 -1
- package/dist/locales/hi.d.ts.map +0 -1
- package/dist/locales/hi.js.map +0 -1
- package/dist/locales/id.d.ts.map +0 -1
- package/dist/locales/id.js.map +0 -1
- package/dist/locales/index.d.ts.map +0 -1
- package/dist/locales/index.js.map +0 -1
- package/dist/locales/it.d.ts.map +0 -1
- package/dist/locales/it.js.map +0 -1
- package/dist/locales/ja.d.ts.map +0 -1
- package/dist/locales/ja.js.map +0 -1
- package/dist/locales/ko.d.ts.map +0 -1
- package/dist/locales/ko.js.map +0 -1
- package/dist/locales/lazy.d.ts.map +0 -1
- package/dist/locales/lazy.js.map +0 -1
- package/dist/locales/nl.d.ts.map +0 -1
- package/dist/locales/nl.js.map +0 -1
- package/dist/locales/no.d.ts.map +0 -1
- package/dist/locales/no.js.map +0 -1
- package/dist/locales/pl.d.ts.map +0 -1
- package/dist/locales/pl.js.map +0 -1
- package/dist/locales/pt-BR.d.ts.map +0 -1
- package/dist/locales/pt-BR.js.map +0 -1
- package/dist/locales/pt.d.ts.map +0 -1
- package/dist/locales/pt.js.map +0 -1
- package/dist/locales/ru.d.ts.map +0 -1
- package/dist/locales/ru.js.map +0 -1
- package/dist/locales/sv.d.ts.map +0 -1
- package/dist/locales/sv.js.map +0 -1
- package/dist/locales/sw.d.ts.map +0 -1
- package/dist/locales/sw.js.map +0 -1
- package/dist/locales/th.d.ts.map +0 -1
- package/dist/locales/th.js.map +0 -1
- package/dist/locales/tr.d.ts.map +0 -1
- package/dist/locales/tr.js.map +0 -1
- package/dist/locales/types.d.ts.map +0 -1
- package/dist/locales/vi.d.ts.map +0 -1
- package/dist/locales/vi.js.map +0 -1
- package/dist/locales/zh.d.ts.map +0 -1
- package/dist/locales/zh.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mini.d.ts.map +0 -1
- package/dist/mini.js.map +0 -1
- package/dist/pigment.d.ts.map +0 -1
- package/dist/pigment.js.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/utils/codec-utils.d.ts.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/ip-validation.d.ts.map +0 -1
- package/dist/utils/security.d.ts.map +0 -1
- package/dist/validators/any.d.ts.map +0 -1
- package/dist/validators/array.d.ts.map +0 -1
- package/dist/validators/base.d.ts.map +0 -1
- package/dist/validators/base64.d.ts.map +0 -1
- package/dist/validators/bigint.d.ts.map +0 -1
- package/dist/validators/boolean.d.ts.map +0 -1
- package/dist/validators/codec.d.ts.map +0 -1
- package/dist/validators/custom.d.ts.map +0 -1
- package/dist/validators/date.d.ts.map +0 -1
- package/dist/validators/discriminated-union.d.ts.map +0 -1
- package/dist/validators/enum.d.ts.map +0 -1
- package/dist/validators/file.d.ts.map +0 -1
- package/dist/validators/function.d.ts.map +0 -1
- package/dist/validators/hex.d.ts.map +0 -1
- package/dist/validators/index.d.ts.map +0 -1
- package/dist/validators/index.js.map +0 -1
- package/dist/validators/intersection.d.ts.map +0 -1
- package/dist/validators/json.d.ts.map +0 -1
- package/dist/validators/lazy.d.ts.map +0 -1
- package/dist/validators/literal.d.ts.map +0 -1
- package/dist/validators/map.d.ts.map +0 -1
- package/dist/validators/nan.d.ts.map +0 -1
- package/dist/validators/never.d.ts.map +0 -1
- package/dist/validators/null.d.ts.map +0 -1
- package/dist/validators/number.d.ts.map +0 -1
- package/dist/validators/object.d.ts.map +0 -1
- package/dist/validators/record.d.ts.map +0 -1
- package/dist/validators/set.d.ts.map +0 -1
- package/dist/validators/string-bool.d.ts.map +0 -1
- package/dist/validators/string-formats.d.ts.map +0 -1
- package/dist/validators/string.d.ts.map +0 -1
- package/dist/validators/symbol.d.ts.map +0 -1
- package/dist/validators/template-literal.d.ts.map +0 -1
- package/dist/validators/tuple.d.ts.map +0 -1
- package/dist/validators/uint8array.d.ts.map +0 -1
- package/dist/validators/undefined.d.ts.map +0 -1
- package/dist/validators/union.d.ts.map +0 -1
- package/dist/validators/unknown.d.ts.map +0 -1
- package/dist/validators/void.d.ts.map +0 -1
- package/dist/validators/xor.d.ts.map +0 -1
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
|
|
2
|
+
import { getMessages } from '../locales/runtime.js';
|
|
3
|
+
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
4
|
+
|
|
5
|
+
function createArrayError(message) {
|
|
6
|
+
return new VldError([{ code: 'invalid_array', path: [], message }]);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Immutable array validator with chainable methods
|
|
10
|
+
*/
|
|
11
|
+
class VldArray extends VldBase {
|
|
12
|
+
/**
|
|
13
|
+
* Private constructor to enforce immutability
|
|
14
|
+
*/
|
|
15
|
+
constructor(config) {
|
|
16
|
+
super(VLD_VALIDATOR_TYPES.ARRAY);
|
|
17
|
+
this.config = config;
|
|
18
|
+
this._simpleItemMode = this.getSimpleItemMode(config.itemValidator);
|
|
19
|
+
}
|
|
20
|
+
getSimpleItemMode(itemValidator) {
|
|
21
|
+
if (itemValidator.isSimple !== true) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
switch (itemValidator.validatorType) {
|
|
25
|
+
case VLD_VALIDATOR_TYPES.STRING:
|
|
26
|
+
return 'string';
|
|
27
|
+
case VLD_VALIDATOR_TYPES.NUMBER:
|
|
28
|
+
return 'number';
|
|
29
|
+
case VLD_VALIDATOR_TYPES.BOOLEAN:
|
|
30
|
+
return 'boolean';
|
|
31
|
+
default:
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a new array validator
|
|
37
|
+
*/
|
|
38
|
+
static create(itemValidator) {
|
|
39
|
+
return new VldArray({ itemValidator });
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse and validate an array value
|
|
43
|
+
*/
|
|
44
|
+
parse(value) {
|
|
45
|
+
if (!Array.isArray(value)) {
|
|
46
|
+
throw new Error(this.config.errorMessage || getMessages().invalidArray);
|
|
47
|
+
}
|
|
48
|
+
return this.parseArrayValue(value);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Parse a value that has already passed the array type guard.
|
|
52
|
+
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
53
|
+
*/
|
|
54
|
+
parseKnownArray(value) {
|
|
55
|
+
return this.parseArrayValue(value);
|
|
56
|
+
}
|
|
57
|
+
parseArrayValue(value) {
|
|
58
|
+
// Validate length constraints
|
|
59
|
+
if (this.config.exactLength !== undefined && value.length !== this.config.exactLength) {
|
|
60
|
+
throw new Error(this.config.errorMessage || getMessages().arrayLength(this.config.exactLength));
|
|
61
|
+
}
|
|
62
|
+
if (this.config.minLength !== undefined && value.length < this.config.minLength) {
|
|
63
|
+
throw new Error(this.config.errorMessage || getMessages().arrayMin(this.config.minLength));
|
|
64
|
+
}
|
|
65
|
+
if (this.config.maxLength !== undefined && value.length > this.config.maxLength) {
|
|
66
|
+
throw new Error(this.config.errorMessage || getMessages().arrayMax(this.config.maxLength));
|
|
67
|
+
}
|
|
68
|
+
const length = value.length;
|
|
69
|
+
const result = new Array(length);
|
|
70
|
+
const simpleItemMode = this._simpleItemMode;
|
|
71
|
+
if (simpleItemMode !== undefined) {
|
|
72
|
+
for (let i = 0; i < length; i++) {
|
|
73
|
+
const item = value[i];
|
|
74
|
+
switch (simpleItemMode) {
|
|
75
|
+
case 'string':
|
|
76
|
+
if (typeof item !== 'string') {
|
|
77
|
+
throw new Error(getMessages().arrayItem(i, getMessages().invalidString));
|
|
78
|
+
}
|
|
79
|
+
result[i] = item;
|
|
80
|
+
break;
|
|
81
|
+
case 'number':
|
|
82
|
+
if (typeof item !== 'number' || isNaN(item)) {
|
|
83
|
+
throw new Error(getMessages().arrayItem(i, getMessages().invalidNumber));
|
|
84
|
+
}
|
|
85
|
+
result[i] = item;
|
|
86
|
+
break;
|
|
87
|
+
case 'boolean':
|
|
88
|
+
if (typeof item !== 'boolean') {
|
|
89
|
+
throw new Error(getMessages().arrayItem(i, getMessages().invalidBoolean));
|
|
90
|
+
}
|
|
91
|
+
result[i] = item;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (this.config.unique) {
|
|
96
|
+
this.checkUnique(result);
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
// Validate each item without allocating a ParseResult object per element.
|
|
101
|
+
for (let i = 0; i < length; i++) {
|
|
102
|
+
try {
|
|
103
|
+
result[i] = this.config.itemValidator.parse(value[i]);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
107
|
+
throw new Error(getMessages().arrayItem(i, message));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Check uniqueness if required - optimized with Map-based approach
|
|
111
|
+
if (this.config.unique) {
|
|
112
|
+
this.checkUnique(result);
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Safely parse and validate an array value
|
|
118
|
+
*/
|
|
119
|
+
safeParse(value) {
|
|
120
|
+
try {
|
|
121
|
+
return { success: true, data: this.parse(value) };
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return { success: false, error: createArrayError(error.message) };
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Optimized uniqueness check using Map-based approach
|
|
129
|
+
* Avoids repeated stableStringify calls by caching serialized values
|
|
130
|
+
*/
|
|
131
|
+
checkUnique(items) {
|
|
132
|
+
const seen = new Set(); // Set of seen keys
|
|
133
|
+
const objectKeys = new WeakMap(); // Cache for object->string mappings
|
|
134
|
+
for (const item of items) {
|
|
135
|
+
let key;
|
|
136
|
+
if (typeof item === 'object' && item !== null) {
|
|
137
|
+
// Check if we've already serialized this object reference
|
|
138
|
+
const cached = objectKeys.get(item);
|
|
139
|
+
if (cached !== undefined) {
|
|
140
|
+
key = cached;
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
// Serialize and cache
|
|
144
|
+
const serialized = this.stableStringify(item);
|
|
145
|
+
key = serialized;
|
|
146
|
+
objectKeys.set(item, serialized);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
// Primitives can be used directly as keys
|
|
151
|
+
key = item;
|
|
152
|
+
}
|
|
153
|
+
if (seen.has(key)) {
|
|
154
|
+
throw new Error('Array must contain unique items');
|
|
155
|
+
}
|
|
156
|
+
seen.add(key);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Create a stable string representation of an object for hashing
|
|
161
|
+
* Handles circular references and deep nesting gracefully
|
|
162
|
+
* BUG-006 FIX: Added depth limit to prevent stack overflow
|
|
163
|
+
* BUG-NEW-003 FIX: Fixed depth tracking to properly track recursion depth
|
|
164
|
+
*/
|
|
165
|
+
stableStringify(obj) {
|
|
166
|
+
const seen = new WeakSet();
|
|
167
|
+
const MAX_DEPTH = 100; // Reasonable depth limit to prevent stack overflow
|
|
168
|
+
// Helper function to sort keys and create stable representation
|
|
169
|
+
const sortedStringify = (value, depth = 0) => {
|
|
170
|
+
// Check depth limit
|
|
171
|
+
if (depth > MAX_DEPTH) {
|
|
172
|
+
return '"[Max Depth Exceeded]"';
|
|
173
|
+
}
|
|
174
|
+
// Handle primitives
|
|
175
|
+
if (value === null)
|
|
176
|
+
return 'null';
|
|
177
|
+
if (value === undefined)
|
|
178
|
+
return 'undefined';
|
|
179
|
+
if (typeof value !== 'object')
|
|
180
|
+
return JSON.stringify(value);
|
|
181
|
+
// Handle circular references
|
|
182
|
+
if (seen.has(value)) {
|
|
183
|
+
return '"[Circular]"';
|
|
184
|
+
}
|
|
185
|
+
seen.add(value);
|
|
186
|
+
try {
|
|
187
|
+
// Handle arrays
|
|
188
|
+
if (Array.isArray(value)) {
|
|
189
|
+
const items = value.map(item => sortedStringify(item, depth + 1));
|
|
190
|
+
return `[${items.join(',')}]`;
|
|
191
|
+
}
|
|
192
|
+
// Handle objects - sort keys for stability
|
|
193
|
+
const keys = Object.keys(value).sort();
|
|
194
|
+
const pairs = keys.map(key => {
|
|
195
|
+
const serializedKey = JSON.stringify(key);
|
|
196
|
+
const serializedValue = sortedStringify(value[key], depth + 1);
|
|
197
|
+
return `${serializedKey}:${serializedValue}`;
|
|
198
|
+
});
|
|
199
|
+
return `{${pairs.join(',')}}`;
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
// Clean up seen set for this branch
|
|
203
|
+
seen.delete(value);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
try {
|
|
207
|
+
return sortedStringify(obj);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
// Fallback to safe representation if stringify fails
|
|
211
|
+
return String(obj);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Create a new validator with minimum length constraint
|
|
216
|
+
*/
|
|
217
|
+
min(length, message) {
|
|
218
|
+
return new VldArray({
|
|
219
|
+
...this.config,
|
|
220
|
+
minLength: length,
|
|
221
|
+
errorMessage: message || getMessages().arrayMin(length)
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Create a new validator with maximum length constraint
|
|
226
|
+
*/
|
|
227
|
+
max(length, message) {
|
|
228
|
+
return new VldArray({
|
|
229
|
+
...this.config,
|
|
230
|
+
maxLength: length,
|
|
231
|
+
errorMessage: message || getMessages().arrayMax(length)
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Create a new validator with exact length constraint
|
|
236
|
+
*/
|
|
237
|
+
length(length, message) {
|
|
238
|
+
return new VldArray({
|
|
239
|
+
...this.config,
|
|
240
|
+
exactLength: length,
|
|
241
|
+
minLength: undefined,
|
|
242
|
+
maxLength: undefined,
|
|
243
|
+
errorMessage: message || getMessages().arrayLength(length)
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Create a new validator that ensures array is not empty
|
|
248
|
+
*/
|
|
249
|
+
nonempty(message) {
|
|
250
|
+
return new VldArray({
|
|
251
|
+
...this.config,
|
|
252
|
+
minLength: 1,
|
|
253
|
+
errorMessage: message || getMessages().arrayEmpty
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Create a new validator that ensures array contains unique items
|
|
258
|
+
*/
|
|
259
|
+
unique(message) {
|
|
260
|
+
return new VldArray({
|
|
261
|
+
...this.config,
|
|
262
|
+
unique: true,
|
|
263
|
+
errorMessage: message || 'Array must contain unique items'
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Create a new validator with a range constraint for length
|
|
268
|
+
*/
|
|
269
|
+
between(min, max, message) {
|
|
270
|
+
return new VldArray({
|
|
271
|
+
...this.config,
|
|
272
|
+
minLength: min,
|
|
273
|
+
maxLength: max,
|
|
274
|
+
errorMessage: message || `Array length must be between ${min} and ${max}`
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
export { VldArray };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SchemaRegistry } from '../registry.js';
|
|
1
2
|
/**
|
|
2
3
|
* Base result type for validation
|
|
3
4
|
*/
|
|
@@ -8,6 +9,108 @@ export type ParseResult<T> = {
|
|
|
8
9
|
readonly success: false;
|
|
9
10
|
readonly error: Error;
|
|
10
11
|
};
|
|
12
|
+
export interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
13
|
+
readonly '~standard': StandardTypedV1Props<Input, Output>;
|
|
14
|
+
}
|
|
15
|
+
export interface StandardTypedV1Props<Input = unknown, Output = Input> {
|
|
16
|
+
readonly version: 1;
|
|
17
|
+
readonly vendor: string;
|
|
18
|
+
readonly types?: StandardTypedV1Types<Input, Output> | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface StandardTypedV1Types<Input = unknown, Output = Input> {
|
|
21
|
+
readonly input: Input;
|
|
22
|
+
readonly output: Output;
|
|
23
|
+
}
|
|
24
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> extends StandardTypedV1<Input, Output> {
|
|
25
|
+
readonly '~standard': StandardSchemaV1Props<Input, Output>;
|
|
26
|
+
}
|
|
27
|
+
export interface StandardSchemaV1Props<Input = unknown, Output = Input> extends StandardTypedV1Props<Input, Output> {
|
|
28
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1Options | undefined) => StandardSchemaV1Result<Output> | Promise<StandardSchemaV1Result<Output>>;
|
|
29
|
+
}
|
|
30
|
+
export interface StandardSchemaV1Options {
|
|
31
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
32
|
+
}
|
|
33
|
+
export type StandardSchemaV1Result<Output> = StandardSchemaV1SuccessResult<Output> | StandardSchemaV1FailureResult;
|
|
34
|
+
export interface StandardSchemaV1SuccessResult<Output> {
|
|
35
|
+
readonly value: Output;
|
|
36
|
+
readonly issues?: undefined;
|
|
37
|
+
}
|
|
38
|
+
export interface StandardSchemaV1FailureResult {
|
|
39
|
+
readonly issues: ReadonlyArray<StandardSchemaV1Issue>;
|
|
40
|
+
}
|
|
41
|
+
export interface StandardSchemaV1Issue {
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly path?: ReadonlyArray<PropertyKey | StandardSchemaV1PathSegment> | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface StandardSchemaV1PathSegment {
|
|
46
|
+
readonly key: PropertyKey;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validator type constants for O(1) dispatch
|
|
50
|
+
* Used by VldObject to replace instanceof chains with Map lookups
|
|
51
|
+
*/
|
|
52
|
+
export declare const VLD_VALIDATOR_TYPES: {
|
|
53
|
+
readonly STRING: "string";
|
|
54
|
+
readonly STRING_FORMAT: "stringFormat";
|
|
55
|
+
readonly STRING_BOOL: "stringBool";
|
|
56
|
+
readonly NUMBER: "number";
|
|
57
|
+
readonly BOOLEAN: "boolean";
|
|
58
|
+
readonly DATE: "date";
|
|
59
|
+
readonly BIGINT: "bigint";
|
|
60
|
+
readonly UNDEFINED: "undefined";
|
|
61
|
+
readonly NULL: "null";
|
|
62
|
+
readonly UNKNOWN: "unknown";
|
|
63
|
+
readonly ANY: "any";
|
|
64
|
+
readonly VOID: "void";
|
|
65
|
+
readonly NEVER: "never";
|
|
66
|
+
readonly SYMBOL: "symbol";
|
|
67
|
+
readonly NAN: "nan";
|
|
68
|
+
readonly HEX: "hex";
|
|
69
|
+
readonly BASE64: "base64";
|
|
70
|
+
readonly UINT8_ARRAY: "uint8Array";
|
|
71
|
+
readonly COERCE_STRING: "coerceString";
|
|
72
|
+
readonly COERCE_NUMBER: "coerceNumber";
|
|
73
|
+
readonly COERCE_BOOLEAN: "coerceBoolean";
|
|
74
|
+
readonly COERCE_DATE: "coerceDate";
|
|
75
|
+
readonly COERCE_BIGINT: "coerceBigint";
|
|
76
|
+
readonly OBJECT: "object";
|
|
77
|
+
readonly ARRAY: "array";
|
|
78
|
+
readonly TUPLE: "tuple";
|
|
79
|
+
readonly SET: "set";
|
|
80
|
+
readonly MAP: "map";
|
|
81
|
+
readonly RECORD: "record";
|
|
82
|
+
readonly UNION: "union";
|
|
83
|
+
readonly DISCRIMINATED_UNION: "discriminatedUnion";
|
|
84
|
+
readonly INTERSECTION: "intersection";
|
|
85
|
+
readonly XOR: "xor";
|
|
86
|
+
readonly ENUM: "enum";
|
|
87
|
+
readonly LITERAL: "literal";
|
|
88
|
+
readonly LAZY: "lazy";
|
|
89
|
+
readonly CUSTOM: "custom";
|
|
90
|
+
readonly FUNCTION: "function";
|
|
91
|
+
readonly FILE: "file";
|
|
92
|
+
readonly JSON: "json";
|
|
93
|
+
readonly TEMPLATE_LITERAL: "templateLiteral";
|
|
94
|
+
readonly PROMISE: "promise";
|
|
95
|
+
readonly OPTIONAL: "optional";
|
|
96
|
+
readonly NULLABLE: "nullable";
|
|
97
|
+
readonly NULLISH: "nullish";
|
|
98
|
+
readonly EXACT_OPTIONAL: "exactOptional";
|
|
99
|
+
readonly DEFAULT: "default";
|
|
100
|
+
readonly CATCH: "catch";
|
|
101
|
+
readonly REFINE: "refine";
|
|
102
|
+
readonly TRANSFORM: "transform";
|
|
103
|
+
readonly PIPE: "pipe";
|
|
104
|
+
readonly PREPROCESS: "preprocess";
|
|
105
|
+
readonly SUPER_REFINE: "superRefine";
|
|
106
|
+
readonly BRAND: "brand";
|
|
107
|
+
readonly READONLY: "readonly";
|
|
108
|
+
readonly META: "meta";
|
|
109
|
+
readonly PREFAULT: "prefault";
|
|
110
|
+
readonly PREFault: "prefault";
|
|
111
|
+
readonly CODEC: "codec";
|
|
112
|
+
};
|
|
113
|
+
export type ValidatorType = typeof VLD_VALIDATOR_TYPES[keyof typeof VLD_VALIDATOR_TYPES];
|
|
11
114
|
/**
|
|
12
115
|
* Context for superRefine - allows adding multiple issues
|
|
13
116
|
*/
|
|
@@ -18,11 +121,32 @@ export interface SuperRefineContext {
|
|
|
18
121
|
}): void;
|
|
19
122
|
path: (string | number)[];
|
|
20
123
|
}
|
|
124
|
+
export type ErrorMap = (issue: {
|
|
125
|
+
code?: string;
|
|
126
|
+
input?: unknown;
|
|
127
|
+
path?: (string | number)[];
|
|
128
|
+
}) => string | undefined;
|
|
129
|
+
export type ErrorParam = string | {
|
|
130
|
+
error?: string | ErrorMap;
|
|
131
|
+
message?: string;
|
|
132
|
+
};
|
|
133
|
+
export declare function resolveErrorMessage(error: ErrorParam | undefined, fallback: string): string;
|
|
21
134
|
/**
|
|
22
135
|
* Abstract base class for all validators
|
|
23
136
|
* Implements immutable pattern to prevent memory leaks and race conditions
|
|
24
137
|
*/
|
|
25
138
|
export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
139
|
+
/**
|
|
140
|
+
* Runtime type identifier for O(1) dispatch
|
|
141
|
+
* Used by VldObject instead of instanceof chains
|
|
142
|
+
*/
|
|
143
|
+
readonly validatorType: ValidatorType;
|
|
144
|
+
/**
|
|
145
|
+
* Constructor with runtime type identifier
|
|
146
|
+
* @param validatorType The runtime type identifier
|
|
147
|
+
*/
|
|
148
|
+
constructor(validatorType?: ValidatorType);
|
|
149
|
+
get '~standard'(): StandardSchemaV1Props<unknown, TOutput>;
|
|
26
150
|
/**
|
|
27
151
|
* Parse and validate a value, throwing an error if invalid
|
|
28
152
|
* @param value The value to validate
|
|
@@ -36,6 +160,8 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
|
36
160
|
* @returns A result object with either success and data, or failure and error
|
|
37
161
|
*/
|
|
38
162
|
abstract safeParse(value: unknown): ParseResult<TOutput>;
|
|
163
|
+
parseAsync(value: unknown): Promise<TOutput>;
|
|
164
|
+
safeParseAsync(value: unknown): Promise<ParseResult<TOutput>>;
|
|
39
165
|
/**
|
|
40
166
|
* Check if a value is valid according to this validator
|
|
41
167
|
* @param value The value to check
|
|
@@ -57,7 +183,7 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
|
57
183
|
* @returns A new refined validator
|
|
58
184
|
*/
|
|
59
185
|
refine<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: string): VldRefine<TInput, TOutput, TRefined>;
|
|
60
|
-
refine(predicate: (value: TOutput) => boolean
|
|
186
|
+
refine(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: string): VldRefine<TInput, TOutput, TOutput>;
|
|
61
187
|
/**
|
|
62
188
|
* Advanced refinement with context for adding multiple issues
|
|
63
189
|
* @param refinement The refinement function with context
|
|
@@ -69,7 +195,7 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
|
69
195
|
* @param transformer The transformation function
|
|
70
196
|
* @returns A new transformed validator
|
|
71
197
|
*/
|
|
72
|
-
transform<TTransformed>(transformer: (value: TOutput) => TTransformed): VldTransform<TInput, TOutput, TTransformed>;
|
|
198
|
+
transform<TTransformed>(transformer: (value: TOutput) => TTransformed | Promise<TTransformed>): VldTransform<TInput, TOutput, TTransformed>;
|
|
73
199
|
/**
|
|
74
200
|
* Create a new validator with a default value for undefined inputs
|
|
75
201
|
* @param defaultValue The default value
|
|
@@ -97,6 +223,14 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
|
97
223
|
* @returns A new nullish validator
|
|
98
224
|
*/
|
|
99
225
|
nullish(): VldNullish<TInput, TOutput>;
|
|
226
|
+
/**
|
|
227
|
+
* Make this validator exactly optional - allows undefined but not missing
|
|
228
|
+
* Unlike .optional() which treats missing as undefined, exactOptional()
|
|
229
|
+
* requires the key to be present but allows undefined as a value
|
|
230
|
+
* Zod 4 API parity
|
|
231
|
+
* @returns A new exact optional validator
|
|
232
|
+
*/
|
|
233
|
+
exactOptional(): VldExactOptional<TInput, TOutput>;
|
|
100
234
|
/**
|
|
101
235
|
* Pipe the output of this validator into another validator
|
|
102
236
|
* @param next The next validator to pipe into
|
|
@@ -133,6 +267,72 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
|
|
|
133
267
|
* const lengthSchema = v.string().apply(withLength); // validates string, returns number
|
|
134
268
|
*/
|
|
135
269
|
apply<TNewOutput>(fn: (schema: this) => VldBase<TInput, TNewOutput>): VldBase<TInput, TNewOutput>;
|
|
270
|
+
/**
|
|
271
|
+
* Create a new validator that refines this one with a custom predicate
|
|
272
|
+
* Alias for refine() - check() is the Zod 4 API name
|
|
273
|
+
* @param predicate The refinement predicate
|
|
274
|
+
* @param message Optional custom error message
|
|
275
|
+
* @returns A new refined validator
|
|
276
|
+
*/
|
|
277
|
+
check<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: string): VldRefine<TInput, TOutput, TRefined>;
|
|
278
|
+
check(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: string): VldRefine<TInput, TOutput, TOutput>;
|
|
279
|
+
/**
|
|
280
|
+
* Get metadata for this schema
|
|
281
|
+
* Zod 4 API parity - allows attaching OpenAPI/JSON Schema metadata
|
|
282
|
+
* @returns Metadata object or undefined
|
|
283
|
+
*/
|
|
284
|
+
meta(): SchemaMetadata | undefined;
|
|
285
|
+
/**
|
|
286
|
+
* Set metadata for this schema
|
|
287
|
+
* Zod 4 API parity - allows attaching OpenAPI/JSON Schema metadata
|
|
288
|
+
* @param data Metadata to attach
|
|
289
|
+
* @returns A new validator with the metadata
|
|
290
|
+
*/
|
|
291
|
+
meta(data: Partial<SchemaMetadata>): VldMeta<TInput, TOutput>;
|
|
292
|
+
/**
|
|
293
|
+
* Register this schema in a metadata registry and return the same instance.
|
|
294
|
+
* This mirrors Zod 4's registry convenience API without changing validator
|
|
295
|
+
* immutability.
|
|
296
|
+
*/
|
|
297
|
+
register<TMetadata extends Record<string, unknown>>(targetRegistry: SchemaRegistry<TMetadata>, metadata: TMetadata): this;
|
|
298
|
+
/**
|
|
299
|
+
* Add a description to this schema
|
|
300
|
+
* Zod 4 API parity - convenience method for .meta({ description: ... })
|
|
301
|
+
* @param description The description to add
|
|
302
|
+
* @returns A new validator with the description
|
|
303
|
+
*/
|
|
304
|
+
describe(description: string): VldMeta<TInput, TOutput>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Schema metadata interface for OpenAPI/JSON Schema compatibility
|
|
308
|
+
*/
|
|
309
|
+
export interface SchemaMetadata {
|
|
310
|
+
id?: string;
|
|
311
|
+
title?: string;
|
|
312
|
+
description?: string;
|
|
313
|
+
examples?: unknown[];
|
|
314
|
+
default?: unknown;
|
|
315
|
+
deprecated?: boolean;
|
|
316
|
+
readOnly?: boolean;
|
|
317
|
+
writeOnly?: boolean;
|
|
318
|
+
[key: string]: unknown;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Metadata validator - wraps a schema with metadata
|
|
322
|
+
*/
|
|
323
|
+
export declare class VldMeta<TInput, TOutput> extends VldBase<TInput, TOutput> {
|
|
324
|
+
private readonly baseValidator;
|
|
325
|
+
private readonly metadata;
|
|
326
|
+
constructor(baseValidator: VldBase<TInput, TOutput>, metadata: Partial<SchemaMetadata>);
|
|
327
|
+
parse(value: unknown): TOutput;
|
|
328
|
+
safeParse(value: unknown): ParseResult<TOutput>;
|
|
329
|
+
/**
|
|
330
|
+
* Get the metadata
|
|
331
|
+
*/
|
|
332
|
+
getMeta(): Readonly<Partial<SchemaMetadata>>;
|
|
333
|
+
meta(): SchemaMetadata | undefined;
|
|
334
|
+
meta(data: Partial<SchemaMetadata>): VldMeta<TInput, TOutput>;
|
|
335
|
+
describe(description: string): VldMeta<TInput, TOutput>;
|
|
136
336
|
}
|
|
137
337
|
/**
|
|
138
338
|
* Readonly validator - marks output as readonly
|
|
@@ -166,9 +366,10 @@ export declare class VldRefine<TInput, TBase, TOutput extends TBase = TBase> ext
|
|
|
166
366
|
private readonly baseValidator;
|
|
167
367
|
private readonly predicate;
|
|
168
368
|
private readonly customMessage?;
|
|
169
|
-
constructor(baseValidator: VldBase<TInput, TBase>, predicate: (value: TBase) => boolean
|
|
369
|
+
constructor(baseValidator: VldBase<TInput, TBase>, predicate: (value: TBase) => boolean | Promise<boolean>, customMessage?: string | undefined);
|
|
170
370
|
parse(value: unknown): TOutput;
|
|
171
371
|
safeParse(value: unknown): ParseResult<TOutput>;
|
|
372
|
+
parseAsync(value: unknown): Promise<TOutput>;
|
|
172
373
|
}
|
|
173
374
|
/**
|
|
174
375
|
* Transform validator - transforms data after validation
|
|
@@ -176,9 +377,10 @@ export declare class VldRefine<TInput, TBase, TOutput extends TBase = TBase> ext
|
|
|
176
377
|
export declare class VldTransform<TInput, TBase, TOutput> extends VldBase<TInput, TOutput> {
|
|
177
378
|
private readonly baseValidator;
|
|
178
379
|
private readonly transformer;
|
|
179
|
-
constructor(baseValidator: VldBase<TInput, TBase>, transformer: (value: TBase) => TOutput);
|
|
380
|
+
constructor(baseValidator: VldBase<TInput, TBase>, transformer: (value: TBase) => TOutput | Promise<TOutput>);
|
|
180
381
|
parse(value: unknown): TOutput;
|
|
181
382
|
safeParse(value: unknown): ParseResult<TOutput>;
|
|
383
|
+
parseAsync(value: unknown): Promise<TOutput>;
|
|
182
384
|
}
|
|
183
385
|
/**
|
|
184
386
|
* Default validator - provides default value for undefined
|
|
@@ -218,6 +420,7 @@ export declare class VldPrefault<TInput, TOutput> extends VldBase<TInput | undef
|
|
|
218
420
|
export declare class VldCatch<TInput, TOutput> extends VldBase<TInput, TOutput> {
|
|
219
421
|
private readonly baseValidator;
|
|
220
422
|
private readonly fallbackValue;
|
|
423
|
+
private readonly simpleMode;
|
|
221
424
|
constructor(baseValidator: VldBase<TInput, TOutput>, fallbackValue: TOutput);
|
|
222
425
|
parse(value: unknown): TOutput;
|
|
223
426
|
safeParse(value: unknown): ParseResult<TOutput>;
|
|
@@ -227,17 +430,35 @@ export declare class VldCatch<TInput, TOutput> extends VldBase<TInput, TOutput>
|
|
|
227
430
|
*/
|
|
228
431
|
export declare class VldOptional<TInput, TOutput> extends VldBase<TInput | undefined, TOutput | undefined> {
|
|
229
432
|
private readonly baseValidator;
|
|
433
|
+
private readonly simpleMode;
|
|
230
434
|
constructor(baseValidator: VldBase<TInput, TOutput>);
|
|
435
|
+
private parseSimpleValue;
|
|
231
436
|
static create<TInput, TOutput>(baseValidator: VldBase<TInput, TOutput>): VldOptional<TInput, TOutput>;
|
|
232
437
|
parse(value: unknown): TOutput | undefined;
|
|
233
438
|
safeParse(value: unknown): ParseResult<TOutput | undefined>;
|
|
234
439
|
unwrap(): VldBase<TInput, TOutput>;
|
|
235
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Exact optional validator - allows undefined but requires key presence
|
|
443
|
+
* Unlike Optional which treats missing as undefined, ExactOptional
|
|
444
|
+
* requires the key to be present (not missing from object) but allows undefined
|
|
445
|
+
* Zod 4 API parity
|
|
446
|
+
*/
|
|
447
|
+
export declare class VldExactOptional<TInput, TOutput> extends VldBase<TInput | undefined, TOutput | undefined> {
|
|
448
|
+
private readonly baseValidator;
|
|
449
|
+
private readonly simpleMode;
|
|
450
|
+
constructor(baseValidator: VldBase<TInput, TOutput>);
|
|
451
|
+
static create<TInput, TOutput>(baseValidator: VldBase<TInput, TOutput>): VldExactOptional<TInput, TOutput>;
|
|
452
|
+
parse(value: unknown): TOutput | undefined;
|
|
453
|
+
safeParse(value: unknown): ParseResult<TOutput | undefined>;
|
|
454
|
+
unwrap(): VldBase<TInput, TOutput>;
|
|
455
|
+
}
|
|
236
456
|
/**
|
|
237
457
|
* Nullable validator - allows null
|
|
238
458
|
*/
|
|
239
459
|
export declare class VldNullable<TInput, TOutput> extends VldBase<TInput | null, TOutput | null> {
|
|
240
460
|
private readonly baseValidator;
|
|
461
|
+
private readonly simpleMode;
|
|
241
462
|
constructor(baseValidator: VldBase<TInput, TOutput>);
|
|
242
463
|
static create<TInput, TOutput>(baseValidator: VldBase<TInput, TOutput>): VldNullable<TInput, TOutput>;
|
|
243
464
|
parse(value: unknown): TOutput | null;
|
|
@@ -249,6 +470,7 @@ export declare class VldNullable<TInput, TOutput> extends VldBase<TInput | null,
|
|
|
249
470
|
*/
|
|
250
471
|
export declare class VldNullish<TInput, TOutput> extends VldBase<TInput | null | undefined, TOutput | null | undefined> {
|
|
251
472
|
private readonly baseValidator;
|
|
473
|
+
private readonly simpleMode;
|
|
252
474
|
constructor(baseValidator: VldBase<TInput, TOutput>);
|
|
253
475
|
static create<TInput, TOutput>(baseValidator: VldBase<TInput, TOutput>): VldNullish<TInput, TOutput>;
|
|
254
476
|
parse(value: unknown): TOutput | null | undefined;
|
|
@@ -274,6 +496,8 @@ export declare class VldSuperRefine<TInput, TOutput> extends VldBase<TInput, TOu
|
|
|
274
496
|
constructor(_inner: VldBase<TInput, TOutput>, _refinement: (value: TOutput, ctx: SuperRefineContext) => void | Promise<void>);
|
|
275
497
|
parse(value: unknown): TOutput;
|
|
276
498
|
safeParse(value: unknown): ParseResult<TOutput>;
|
|
499
|
+
parseAsync(value: unknown): Promise<TOutput>;
|
|
500
|
+
safeParseAsync(value: unknown): Promise<ParseResult<TOutput>>;
|
|
277
501
|
}
|
|
278
502
|
/**
|
|
279
503
|
* Preprocess validator - transforms input before validation
|
|
@@ -286,4 +510,3 @@ export declare class VldPreprocess<TInput, TOutput> extends VldBase<unknown, TOu
|
|
|
286
510
|
parse(value: unknown): TOutput;
|
|
287
511
|
safeParse(value: unknown): ParseResult<TOutput>;
|
|
288
512
|
}
|
|
289
|
-
//# sourceMappingURL=base.d.ts.map
|