@oxog/vld 2.0.3 → 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 +33 -1
- package/README.md +101 -37
- package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
- package/dist/chunks/{index-DO8CFMxD.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-50JV_Mfj.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 +1471 -10336
- 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 -7353
- 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 +1186 -835
- package/dist/index.js +1046 -367
- 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 +16 -6
- 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 +150 -6
- 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 -39
- package/dist/validators/index.js +35 -515
- 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 +56 -27
- 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 +15 -10
- 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 +7 -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-Dhzri_T-.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 +114 -30
- package/dist/chunks/bigint-CRS0QVsy.js +0 -1854
- package/dist/chunks/bigint-CRS0QVsy.js.map +0 -1
- package/dist/chunks/date-50JV_Mfj.js.map +0 -1
- package/dist/chunks/index-DO8CFMxD.js.map +0 -1
- package/dist/chunks/json-Cp4WO0M9.js +0 -2021
- package/dist/chunks/json-Cp4WO0M9.js.map +0 -1
- package/dist/chunks/unknown-Dhzri_T-.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/json-schema.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/promise.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
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Main entry point for all validators
|
|
3
3
|
*/
|
|
4
|
-
export { VldBase, ParseResult, VldRefine, VldTransform, VldDefault, VldCatch, VldOptional, VldExactOptional, VldNullable, VldNullish, VldPipe, VldReadonly, VldBrand, SuperRefineContext, VldSuperRefine, VldPreprocess } from './base';
|
|
5
|
-
export { VldString } from './string';
|
|
6
|
-
export { VldNumber } from './number';
|
|
7
|
-
export { VldBoolean } from './boolean';
|
|
8
|
-
export { VldDate } from './date';
|
|
9
|
-
export { VldStringBool } from './string-bool';
|
|
10
|
-
export { VldArray } from './array';
|
|
11
|
-
export { VldObject } from './object';
|
|
12
|
-
export { VldUnion } from './union';
|
|
13
|
-
export { VldIntersection } from './intersection';
|
|
14
|
-
export { VldLiteral } from './literal';
|
|
15
|
-
export { VldEnum } from './enum';
|
|
16
|
-
export { VldTuple } from './tuple';
|
|
17
|
-
export { VldRecord } from './record';
|
|
18
|
-
export { VldSet } from './set';
|
|
19
|
-
export { VldMap } from './map';
|
|
20
|
-
export { VldBigInt } from './bigint';
|
|
21
|
-
export { VldSymbol } from './symbol';
|
|
22
|
-
export { VldAny } from './any';
|
|
23
|
-
export { VldUnknown } from './unknown';
|
|
24
|
-
export { VldVoid } from './void';
|
|
25
|
-
export { VldNever } from './never';
|
|
26
|
-
export { VldNull } from './null';
|
|
27
|
-
export { VldUndefined } from './undefined';
|
|
28
|
-
export { VldNan } from './nan';
|
|
29
|
-
export { VldLazy } from './lazy';
|
|
30
|
-
export { VldDiscriminatedUnion } from './discriminated-union';
|
|
31
|
-
export { VldXor } from './xor';
|
|
32
|
-
export { VldJson } from './json';
|
|
33
|
-
export { VldTemplateLiteral, templateLiteral } from './template-literal';
|
|
34
|
-
export { VldCustom, custom } from './custom';
|
|
35
|
-
export type { CustomValidatorOptions } from './custom';
|
|
36
|
-
export { VldFile, file } from './file';
|
|
37
|
-
export type { VldFileValue } from './file';
|
|
38
|
-
export { VldFunction, functionValidator } from './function';
|
|
39
|
-
export { VldPromise, promise } from './promise';
|
|
40
|
-
export { email, uuid, uuidv4, hostname, emoji, base64, base64url, hex, jwt, nanoid, cuid, cuid2, ulid, ipv4, ipv6, mac, cidrv4, cidrv6, e164, hash, iso, stringFormat, regexes, xid, guid, httpUrl } from './string-formats';
|
|
41
|
-
import { VldBase } from './base';
|
|
4
|
+
export { VldBase, ParseResult, VldRefine, VldTransform, VldDefault, VldCatch, VldOptional, VldExactOptional, VldNullable, VldNullish, VldPipe, VldReadonly, VldBrand, SuperRefineContext, VldSuperRefine, VldPreprocess } from './base.js';
|
|
5
|
+
export { VldString } from './string.js';
|
|
6
|
+
export { VldNumber } from './number.js';
|
|
7
|
+
export { VldBoolean } from './boolean.js';
|
|
8
|
+
export { VldDate } from './date.js';
|
|
9
|
+
export { VldStringBool } from './string-bool.js';
|
|
10
|
+
export { VldArray } from './array.js';
|
|
11
|
+
export { VldObject } from './object.js';
|
|
12
|
+
export { VldUnion } from './union.js';
|
|
13
|
+
export { VldIntersection } from './intersection.js';
|
|
14
|
+
export { VldLiteral } from './literal.js';
|
|
15
|
+
export { VldEnum } from './enum.js';
|
|
16
|
+
export { VldTuple } from './tuple.js';
|
|
17
|
+
export { VldRecord } from './record.js';
|
|
18
|
+
export { VldSet } from './set.js';
|
|
19
|
+
export { VldMap } from './map.js';
|
|
20
|
+
export { VldBigInt } from './bigint.js';
|
|
21
|
+
export { VldSymbol } from './symbol.js';
|
|
22
|
+
export { VldAny } from './any.js';
|
|
23
|
+
export { VldUnknown } from './unknown.js';
|
|
24
|
+
export { VldVoid } from './void.js';
|
|
25
|
+
export { VldNever } from './never.js';
|
|
26
|
+
export { VldNull } from './null.js';
|
|
27
|
+
export { VldUndefined } from './undefined.js';
|
|
28
|
+
export { VldNan } from './nan.js';
|
|
29
|
+
export { VldLazy } from './lazy.js';
|
|
30
|
+
export { VldDiscriminatedUnion } from './discriminated-union.js';
|
|
31
|
+
export { VldXor } from './xor.js';
|
|
32
|
+
export { VldJson } from './json.js';
|
|
33
|
+
export { VldTemplateLiteral, templateLiteral } from './template-literal.js';
|
|
34
|
+
export { VldCustom, custom } from './custom.js';
|
|
35
|
+
export type { CustomValidatorOptions } from './custom.js';
|
|
36
|
+
export { VldFile, file } from './file.js';
|
|
37
|
+
export type { VldFileValue } from './file.js';
|
|
38
|
+
export { VldFunction, functionValidator } from './function.js';
|
|
39
|
+
export { VldPromise, promise } from './promise.js';
|
|
40
|
+
export { email, uuid, uuidv4, hostname, emoji, base64, base64url, hex, jwt, nanoid, cuid, cuid2, ulid, ipv4, ipv6, mac, cidrv4, cidrv6, e164, hash, iso, stringFormat, regexes, xid, guid, httpUrl } from './string-formats.js';
|
|
41
|
+
import { VldBase } from './base.js';
|
|
42
42
|
export type Infer<T extends VldBase<any, any>> = T extends VldBase<any, infer U> ? U : never;
|
|
43
43
|
export type Input<T extends VldBase<any, any>> = T extends VldBase<infer I, any> ? I : never;
|
|
44
44
|
export type Output<T extends VldBase<any, any>> = T extends VldBase<any, infer O> ? O : never;
|
|
45
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/validators/index.js
CHANGED
|
@@ -1,515 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
export { V as
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
parse(value) {
|
|
38
|
-
if (typeof value !== 'string') {
|
|
39
|
-
throw new Error(getMessages().invalidString);
|
|
40
|
-
}
|
|
41
|
-
if (!this.pattern.test(value)) {
|
|
42
|
-
throw new Error(getMessages().stringPatternInvalid);
|
|
43
|
-
}
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Safely parse and validate a template literal string
|
|
48
|
-
*/
|
|
49
|
-
safeParse(value) {
|
|
50
|
-
try {
|
|
51
|
-
return { success: true, data: this.parse(value) };
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
return {
|
|
55
|
-
success: false,
|
|
56
|
-
error: error
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get regex pattern for a validator type
|
|
63
|
-
*/
|
|
64
|
-
function getPatternForValidator(validator) {
|
|
65
|
-
// For template literals, we need to identify the validator type
|
|
66
|
-
// and return an appropriate capture group pattern
|
|
67
|
-
const className = validator.constructor.name;
|
|
68
|
-
// Check for specific validator types
|
|
69
|
-
if (className === 'VldString') {
|
|
70
|
-
return '(.+)';
|
|
71
|
-
}
|
|
72
|
-
if (className === 'VldNumber' || className === 'VldInt') {
|
|
73
|
-
return '(-?\\d+(?:\\.\\d+)?)';
|
|
74
|
-
}
|
|
75
|
-
if (className === 'VldBigInt') {
|
|
76
|
-
return '(-?\\d+)';
|
|
77
|
-
}
|
|
78
|
-
if (className === 'VldBoolean') {
|
|
79
|
-
return '(true|false)';
|
|
80
|
-
}
|
|
81
|
-
if (className === 'VldNull') {
|
|
82
|
-
return '(null)';
|
|
83
|
-
}
|
|
84
|
-
if (className === 'VldUndefined' || className === 'VldVoid') {
|
|
85
|
-
return '(undefined)';
|
|
86
|
-
}
|
|
87
|
-
if (className === 'VldLiteral') {
|
|
88
|
-
// Extract literal value - access private literal property via any
|
|
89
|
-
const literalValidator = validator;
|
|
90
|
-
if (literalValidator.literal !== undefined) {
|
|
91
|
-
const valueStr = String(literalValidator.literal);
|
|
92
|
-
return '(' + valueStr.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + ')';
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
// Default: match any string
|
|
96
|
-
return '(.+)';
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Helper function to create template literal validators
|
|
100
|
-
* Usage: v.templateLiteral(v.string(), '-', v.number())
|
|
101
|
-
*/
|
|
102
|
-
function templateLiteral(...components) {
|
|
103
|
-
return VldTemplateLiteral.create(...components);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Immutable custom validator for user-defined validation logic
|
|
108
|
-
* Provides type safety while allowing complete control over validation
|
|
109
|
-
*/
|
|
110
|
-
class VldCustom extends VldBase {
|
|
111
|
-
constructor(options) {
|
|
112
|
-
super();
|
|
113
|
-
this._parseFn = options.parse;
|
|
114
|
-
this._safeParseFn = options.safeParse || ((value) => {
|
|
115
|
-
try {
|
|
116
|
-
return { success: true, data: this._parseFn(value) };
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
return { success: false, error: error };
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Create a new custom validator
|
|
125
|
-
*/
|
|
126
|
-
static create(options) {
|
|
127
|
-
return new VldCustom(options);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Parse and validate using the custom parse function
|
|
131
|
-
*/
|
|
132
|
-
parse(value) {
|
|
133
|
-
return this._parseFn(value);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Safely parse using the custom safeParse function or default implementation
|
|
137
|
-
*/
|
|
138
|
-
safeParse(value) {
|
|
139
|
-
return this._safeParseFn(value);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Helper function to create custom validators
|
|
144
|
-
* Usage: v.custom<number>({
|
|
145
|
-
* parse: (value) => {
|
|
146
|
-
* if (typeof value !== 'string') throw new Error('Expected string');
|
|
147
|
-
* return parseInt(value, 10);
|
|
148
|
-
* }
|
|
149
|
-
* })
|
|
150
|
-
*/
|
|
151
|
-
function custom(options) {
|
|
152
|
-
return VldCustom.create(options);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Immutable file validator for file uploads
|
|
157
|
-
* Supports size and MIME type validation
|
|
158
|
-
*/
|
|
159
|
-
class VldFile extends VldBase {
|
|
160
|
-
constructor(checks = []) {
|
|
161
|
-
super();
|
|
162
|
-
this.checks = checks;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Create a new file validator
|
|
166
|
-
*/
|
|
167
|
-
static create() {
|
|
168
|
-
return new VldFile();
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Parse and validate a file value
|
|
172
|
-
*/
|
|
173
|
-
parse(value) {
|
|
174
|
-
// Check if File API is supported
|
|
175
|
-
const FileSupported = typeof File !== 'undefined';
|
|
176
|
-
if (!FileSupported) {
|
|
177
|
-
throw new Error(getMessages().fileNotSupported || 'File API not supported in this environment');
|
|
178
|
-
}
|
|
179
|
-
// Check if value is a File object
|
|
180
|
-
if (!(value instanceof File)) {
|
|
181
|
-
// Allow plain object with size and type for Node.js compatibility
|
|
182
|
-
if (typeof value === 'object' &&
|
|
183
|
-
value !== null &&
|
|
184
|
-
'size' in value &&
|
|
185
|
-
'type' in value) {
|
|
186
|
-
const fileObj = value;
|
|
187
|
-
return this.runChecks(fileObj);
|
|
188
|
-
}
|
|
189
|
-
throw new Error(getMessages().invalidFile || 'Expected a File object');
|
|
190
|
-
}
|
|
191
|
-
return this.runChecks(value);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Run all validation checks on the file
|
|
195
|
-
*/
|
|
196
|
-
runChecks(file) {
|
|
197
|
-
const msgs = getMessages();
|
|
198
|
-
for (const check of this.checks) {
|
|
199
|
-
switch (check.type) {
|
|
200
|
-
case 'min':
|
|
201
|
-
if (file.size < check.value) {
|
|
202
|
-
throw new Error(check.message ||
|
|
203
|
-
(msgs.fileMinSize?.(check.value) || `File size must be at least ${check.value} bytes`));
|
|
204
|
-
}
|
|
205
|
-
break;
|
|
206
|
-
case 'max':
|
|
207
|
-
if (file.size > check.value) {
|
|
208
|
-
throw new Error(check.message ||
|
|
209
|
-
(msgs.fileMaxSize?.(check.value) || `File size must not exceed ${check.value} bytes`));
|
|
210
|
-
}
|
|
211
|
-
break;
|
|
212
|
-
case 'mime':
|
|
213
|
-
if (!check.value.includes(file.type)) {
|
|
214
|
-
throw new Error(check.message ||
|
|
215
|
-
(msgs.fileMimeType?.(check.value) || `Invalid file type. Expected: ${check.value.join(', ')}`));
|
|
216
|
-
}
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return file;
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Safely parse and validate a file value
|
|
224
|
-
*/
|
|
225
|
-
safeParse(value) {
|
|
226
|
-
try {
|
|
227
|
-
return { success: true, data: this.parse(value) };
|
|
228
|
-
}
|
|
229
|
-
catch (error) {
|
|
230
|
-
return { success: false, error: error };
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Set minimum file size in bytes
|
|
235
|
-
*/
|
|
236
|
-
min(bytes, message) {
|
|
237
|
-
return new VldFile([...this.checks, { type: 'min', value: bytes, message }]);
|
|
238
|
-
}
|
|
239
|
-
/**
|
|
240
|
-
* Set maximum file size in bytes
|
|
241
|
-
*/
|
|
242
|
-
max(bytes, message) {
|
|
243
|
-
return new VldFile([...this.checks, { type: 'max', value: bytes, message }]);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Set allowed MIME types
|
|
247
|
-
*/
|
|
248
|
-
mime(types, message) {
|
|
249
|
-
const typeArray = Array.isArray(types) ? types : [types];
|
|
250
|
-
return new VldFile([...this.checks, { type: 'mime', value: typeArray, message }]);
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* Set both minimum and maximum file size
|
|
254
|
-
*/
|
|
255
|
-
size(min, max, message) {
|
|
256
|
-
return this.min(min, message).max(max, message);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* Helper function to create file validators
|
|
261
|
-
* Usage: v.file().min(1024).max(10485760).mime(['image/jpeg', 'image/png'])
|
|
262
|
-
*/
|
|
263
|
-
function file() {
|
|
264
|
-
return VldFile.create();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* Immutable function validator
|
|
269
|
-
* Validates that a value is a function
|
|
270
|
-
*/
|
|
271
|
-
class VldFunction extends VldBase {
|
|
272
|
-
constructor() {
|
|
273
|
-
super();
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Create a new function validator
|
|
277
|
-
*/
|
|
278
|
-
static create() {
|
|
279
|
-
return new VldFunction();
|
|
280
|
-
}
|
|
281
|
-
/**
|
|
282
|
-
* Parse and validate a function value
|
|
283
|
-
*/
|
|
284
|
-
parse(value) {
|
|
285
|
-
if (typeof value !== 'function') {
|
|
286
|
-
throw new Error(getMessages().invalidFunction || 'Expected a function');
|
|
287
|
-
}
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Safely parse and validate a function value
|
|
292
|
-
*/
|
|
293
|
-
safeParse(value) {
|
|
294
|
-
try {
|
|
295
|
-
return { success: true, data: this.parse(value) };
|
|
296
|
-
}
|
|
297
|
-
catch (error) {
|
|
298
|
-
return { success: false, error: error };
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Helper function to create function validators
|
|
304
|
-
* Usage: v.function()
|
|
305
|
-
*/
|
|
306
|
-
function functionValidator() {
|
|
307
|
-
return VldFunction.create();
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
/**
|
|
311
|
-
* Promise validator - validates Promise values
|
|
312
|
-
* Validates that the resolved value matches the inner schema
|
|
313
|
-
*/
|
|
314
|
-
/**
|
|
315
|
-
* Promise validator - validates Promise<T> where T matches inner schema
|
|
316
|
-
* Zod 4 API parity - allows async validation with proper type inference
|
|
317
|
-
*
|
|
318
|
-
* Validates that the input is a Promise, and validates the resolved value
|
|
319
|
-
* against the inner schema when parsed.
|
|
320
|
-
*
|
|
321
|
-
* Use parseAsync() or safeParseAsync() for proper async handling.
|
|
322
|
-
*/
|
|
323
|
-
class VldPromise {
|
|
324
|
-
constructor(inner) {
|
|
325
|
-
this.inner = inner;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* Check if value is thenable (Promise-like)
|
|
329
|
-
* Must be called BEFORE wrapping in Promise.resolve
|
|
330
|
-
*/
|
|
331
|
-
_isThenable(value) {
|
|
332
|
-
return value !== null && typeof value.then === 'function';
|
|
333
|
-
}
|
|
334
|
-
/**
|
|
335
|
-
* Parse and validate a Promise value asynchronously
|
|
336
|
-
* @param value The Promise to validate
|
|
337
|
-
* @returns The validated value
|
|
338
|
-
* @throws {Error} If validation fails when Promise resolves
|
|
339
|
-
*/
|
|
340
|
-
async parse(value) {
|
|
341
|
-
// Check if value is thenable BEFORE wrapping in Promise.resolve
|
|
342
|
-
if (!this._isThenable(value)) {
|
|
343
|
-
throw new Error('Expected a Promise value');
|
|
344
|
-
}
|
|
345
|
-
// Now we can safely await it
|
|
346
|
-
const resolved = await Promise.resolve(value);
|
|
347
|
-
return this.inner.parse(resolved);
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Safely parse and validate a Promise value asynchronously
|
|
351
|
-
* @param value The Promise to validate
|
|
352
|
-
* @returns A Promise resolving to ParseResult containing the validated value
|
|
353
|
-
*/
|
|
354
|
-
async safeParse(value) {
|
|
355
|
-
// Check if value is thenable BEFORE wrapping in Promise.resolve
|
|
356
|
-
if (!this._isThenable(value)) {
|
|
357
|
-
return {
|
|
358
|
-
success: false,
|
|
359
|
-
error: new Error('Expected a Promise value')
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
try {
|
|
363
|
-
const resolved = await Promise.resolve(value);
|
|
364
|
-
const validated = this.inner.parse(resolved);
|
|
365
|
-
return {
|
|
366
|
-
success: true,
|
|
367
|
-
data: validated
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
catch (err) {
|
|
371
|
-
return {
|
|
372
|
-
success: false,
|
|
373
|
-
error: err instanceof Error ? err : new Error(String(err))
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Create a Promise validator
|
|
380
|
-
* @param inner The schema to validate the resolved value against
|
|
381
|
-
* @returns A new Promise validator
|
|
382
|
-
* @example
|
|
383
|
-
* const promiseSchema = v.promise(v.string());
|
|
384
|
-
* const result = await promiseSchema.parse(Promise.resolve("hello"));
|
|
385
|
-
* // result is string
|
|
386
|
-
*/
|
|
387
|
-
function promise(inner) {
|
|
388
|
-
return new VldPromise(inner);
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* Top-level string format validators
|
|
393
|
-
* Part of Zod 4 API parity implementation
|
|
394
|
-
* Provides convenient validators for common string formats
|
|
395
|
-
*/
|
|
396
|
-
/**
|
|
397
|
-
* Pre-compiled regex patterns for performance
|
|
398
|
-
*/
|
|
399
|
-
const REGEXES = {
|
|
400
|
-
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
401
|
-
uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
402
|
-
uuidv4: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
403
|
-
uuidv6: /^[0-9a-f]{8}-[0-9a-f]{4}-6[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
404
|
-
uuidv7: /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
405
|
-
hostname: /^(?=.{1,253}$)(?:(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$/,
|
|
406
|
-
emoji: /^(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F)(?:\u200D(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F))*$/u,
|
|
407
|
-
base64: /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/,
|
|
408
|
-
base64url: /^[A-Za-z0-9_-]*$/,
|
|
409
|
-
hex: /^[0-9a-fA-F]*$/,
|
|
410
|
-
jwt: /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$/,
|
|
411
|
-
nanoid: /^[A-Za-z0-9_-]{21}$/,
|
|
412
|
-
cuid: /^c[^\s-]{8,}$/i,
|
|
413
|
-
cuid2: /^[0-9a-z]+$/,
|
|
414
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
415
|
-
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
416
|
-
ipv6: /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
|
|
417
|
-
mac: /^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/,
|
|
418
|
-
cidrv4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(?:3[0-2]|[12]?[0-9])$/,
|
|
419
|
-
cidrv6: /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^(?:[0-9a-fA-F]{1,4}:){1,7}:\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
420
|
-
e164: /^\+[1-9]\d{1,14}$/,
|
|
421
|
-
isoDate: /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/,
|
|
422
|
-
isoTime: /^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?$/,
|
|
423
|
-
isoDateTime: /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?Z?$/,
|
|
424
|
-
md5: /^[a-f0-9]{32}$/i,
|
|
425
|
-
sha1: /^[a-f0-9]{40}$/i,
|
|
426
|
-
sha256: /^[a-f0-9]{64}$/i,
|
|
427
|
-
sha384: /^[a-f0-9]{96}$/i,
|
|
428
|
-
sha512: /^[a-f0-9]{128}$/i,
|
|
429
|
-
// Additional formats (Zod v4 parity)
|
|
430
|
-
xid: /^[A-HJKMNP-TV-Z0-9]{20}$/, // ksort's XID format
|
|
431
|
-
guid: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i, // Alias for UUID
|
|
432
|
-
httpUrl: /^https?:\/\/[^\s/$.?#].[^\s]*$/, // HTTP/HTTPS URL
|
|
433
|
-
};
|
|
434
|
-
/**
|
|
435
|
-
* Generic string format validator
|
|
436
|
-
*/
|
|
437
|
-
class VldStringFormat extends VldBase {
|
|
438
|
-
constructor(_format, _validator, _errorMessage) {
|
|
439
|
-
super();
|
|
440
|
-
this._format = _format;
|
|
441
|
-
this._validator = _validator;
|
|
442
|
-
this._errorMessage = _errorMessage;
|
|
443
|
-
}
|
|
444
|
-
static create(format, validator, errorMessage) {
|
|
445
|
-
return new VldStringFormat(format, validator, errorMessage);
|
|
446
|
-
}
|
|
447
|
-
parse(value) {
|
|
448
|
-
const result = VldString.create().parse(value);
|
|
449
|
-
if (!this._validator(result)) {
|
|
450
|
-
throw new Error(this._errorMessage || `Invalid ${this._format} format`);
|
|
451
|
-
}
|
|
452
|
-
return result;
|
|
453
|
-
}
|
|
454
|
-
safeParse(value) {
|
|
455
|
-
const stringResult = VldString.create().safeParse(value);
|
|
456
|
-
if (!stringResult.success) {
|
|
457
|
-
return stringResult;
|
|
458
|
-
}
|
|
459
|
-
if (!this._validator(stringResult.data)) {
|
|
460
|
-
return {
|
|
461
|
-
success: false,
|
|
462
|
-
error: new Error(this._errorMessage || `Invalid ${this._format} format`)
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
return { success: true, data: stringResult.data };
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
/**
|
|
469
|
-
* Top-level string format validators
|
|
470
|
-
*/
|
|
471
|
-
const email = (options) => VldStringFormat.create('email', (val) => (options?.pattern ?? REGEXES.email).test(val));
|
|
472
|
-
const uuid = (options) => {
|
|
473
|
-
const pattern = options?.version ? REGEXES[`uuid${options.version}`] : REGEXES.uuid;
|
|
474
|
-
return VldStringFormat.create('uuid', (val) => pattern.test(val));
|
|
475
|
-
};
|
|
476
|
-
const uuidv4 = () => VldStringFormat.create('uuid', (val) => REGEXES.uuidv4.test(val));
|
|
477
|
-
const hostname = () => VldStringFormat.create('hostname', (val) => REGEXES.hostname.test(val));
|
|
478
|
-
const emoji = () => VldStringFormat.create('emoji', (val) => REGEXES.emoji.test(val));
|
|
479
|
-
const base64 = () => VldStringFormat.create('base64', (val) => REGEXES.base64.test(val));
|
|
480
|
-
const base64url = () => VldStringFormat.create('base64url', (val) => REGEXES.base64url.test(val));
|
|
481
|
-
const hex = () => VldStringFormat.create('hex', (val) => REGEXES.hex.test(val));
|
|
482
|
-
const jwt = () => VldStringFormat.create('jwt', (val) => REGEXES.jwt.test(val));
|
|
483
|
-
const nanoid = () => VldStringFormat.create('nanoid', (val) => REGEXES.nanoid.test(val));
|
|
484
|
-
const cuid = () => VldStringFormat.create('cuid', (val) => REGEXES.cuid.test(val));
|
|
485
|
-
const cuid2 = () => VldStringFormat.create('cuid2', (val) => REGEXES.cuid2.test(val));
|
|
486
|
-
const ulid = () => VldStringFormat.create('ulid', (val) => REGEXES.ulid.test(val));
|
|
487
|
-
const ipv4 = () => VldStringFormat.create('ipv4', (val) => REGEXES.ipv4.test(val));
|
|
488
|
-
const ipv6 = () => VldStringFormat.create('ipv6', (val) => REGEXES.ipv6.test(val));
|
|
489
|
-
const mac = () => VldStringFormat.create('mac', (val) => REGEXES.mac.test(val));
|
|
490
|
-
const cidrv4 = () => VldStringFormat.create('cidrv4', (val) => REGEXES.cidrv4.test(val));
|
|
491
|
-
const cidrv6 = () => VldStringFormat.create('cidrv6', (val) => REGEXES.cidrv6.test(val));
|
|
492
|
-
const e164 = () => VldStringFormat.create('e164', (val) => REGEXES.e164.test(val));
|
|
493
|
-
const xid = () => VldStringFormat.create('xid', (val) => REGEXES.xid.test(val));
|
|
494
|
-
const guid = () => VldStringFormat.create('guid', (val) => REGEXES.guid.test(val));
|
|
495
|
-
const httpUrl = () => VldStringFormat.create('httpUrl', (val) => REGEXES.httpUrl.test(val));
|
|
496
|
-
const hash = (algorithm) => VldStringFormat.create('hash', (val) => REGEXES[algorithm]?.test(val) ?? false, `Invalid ${algorithm} hash`);
|
|
497
|
-
/**
|
|
498
|
-
* ISO date/time validators
|
|
499
|
-
*/
|
|
500
|
-
const iso = {
|
|
501
|
-
date: () => VldStringFormat.create('date', (val) => REGEXES.isoDate.test(val)),
|
|
502
|
-
time: () => VldStringFormat.create('time', (val) => REGEXES.isoTime.test(val)),
|
|
503
|
-
dateTime: (_options) => VldStringFormat.create('datetime', (val) => REGEXES.isoDateTime.test(val)),
|
|
504
|
-
duration: () => VldStringFormat.create('duration', (val) => /^P/.test(val)),
|
|
505
|
-
};
|
|
506
|
-
/**
|
|
507
|
-
* Custom format validator
|
|
508
|
-
*/
|
|
509
|
-
const stringFormat = (name, validator) => {
|
|
510
|
-
const fn = validator instanceof RegExp ? (val) => validator.test(val) : validator;
|
|
511
|
-
return VldStringFormat.create(name, fn);
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
export { VldBase, VldCustom, VldFile, VldFunction, VldPromise, VldString, VldTemplateLiteral, base64, base64url, cidrv4, cidrv6, cuid, cuid2, custom, e164, email, emoji, file, functionValidator, guid, hash, hex, hostname, httpUrl, ipv4, ipv6, iso, jwt, mac, nanoid, promise, REGEXES as regexes, stringFormat, templateLiteral, ulid, uuid, uuidv4, xid };
|
|
515
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { VldBase, VldBrand, VldCatch, VldDefault, VldExactOptional, VldNullable, VldNullish, VldOptional, VldPipe, VldPreprocess, VldReadonly, VldRefine, VldSuperRefine, VldTransform } from './base.js';
|
|
2
|
+
export { V as VldString } from '../chunks/string-BJRQod3t.js';
|
|
3
|
+
export { VldNumber } from './number.js';
|
|
4
|
+
export { VldBoolean } from './boolean.js';
|
|
5
|
+
export { VldDate } from './date.js';
|
|
6
|
+
export { VldStringBool } from './string-bool.js';
|
|
7
|
+
export { VldArray } from './array.js';
|
|
8
|
+
export { VldObject } from './object.js';
|
|
9
|
+
export { VldUnion } from './union.js';
|
|
10
|
+
export { VldIntersection } from './intersection.js';
|
|
11
|
+
export { VldLiteral } from './literal.js';
|
|
12
|
+
export { VldEnum } from './enum.js';
|
|
13
|
+
export { VldTuple } from './tuple.js';
|
|
14
|
+
export { VldRecord } from './record.js';
|
|
15
|
+
export { VldSet } from './set.js';
|
|
16
|
+
export { VldMap } from './map.js';
|
|
17
|
+
export { VldBigInt } from './bigint.js';
|
|
18
|
+
export { VldSymbol } from './symbol.js';
|
|
19
|
+
export { VldAny } from './any.js';
|
|
20
|
+
export { VldUnknown } from './unknown.js';
|
|
21
|
+
export { VldVoid } from './void.js';
|
|
22
|
+
export { VldNever } from './never.js';
|
|
23
|
+
export { VldNull } from './null.js';
|
|
24
|
+
export { VldUndefined } from './undefined.js';
|
|
25
|
+
export { VldNan } from './nan.js';
|
|
26
|
+
export { VldLazy } from './lazy.js';
|
|
27
|
+
export { VldDiscriminatedUnion } from './discriminated-union.js';
|
|
28
|
+
export { VldXor } from './xor.js';
|
|
29
|
+
export { VldJson } from './json.js';
|
|
30
|
+
export { VldTemplateLiteral, templateLiteral } from './template-literal.js';
|
|
31
|
+
export { VldCustom, custom } from './custom.js';
|
|
32
|
+
export { VldFile, file } from './file.js';
|
|
33
|
+
export { VldFunction, functionValidator } from './function.js';
|
|
34
|
+
export { VldPromise, promise } from './promise.js';
|
|
35
|
+
export { base64, base64url, cidrv4, cidrv6, cuid, cuid2, e164, email, emoji, guid, hash, hex, hostname, httpUrl, ipv4, ipv6, iso, jwt, mac, nanoid, regexes, stringFormat, ulid, uuid, uuidv4, xid } from './string-formats.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VldBase, ParseResult } from './base';
|
|
1
|
+
import { VldBase, ParseResult } from './base.js';
|
|
2
2
|
/**
|
|
3
3
|
* Immutable intersection validator for combining validators
|
|
4
4
|
*/
|
|
@@ -22,4 +22,3 @@ export declare class VldIntersection<A, B> extends VldBase<unknown, A & B> {
|
|
|
22
22
|
*/
|
|
23
23
|
safeParse(value: unknown): ParseResult<A & B>;
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=intersection.d.ts.map
|