@oxog/vld 2.0.3 → 2.2.5
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 +120 -1
- package/README.md +1296 -1171
- package/dist/chunks/errors-core-Cqi4-9ew.js +1 -0
- package/dist/chunks/index-CkbfQQ4n.js +1 -0
- package/dist/chunks/index-yjpbvFgw.js +1 -0
- package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
- package/dist/chunks/security-Dy24T8N7.js +1 -0
- package/dist/cjs/chunks/errors-core-DKPohm9I.cjs +1 -0
- package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
- package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
- package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
- package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
- package/dist/cjs/cli/bin.cjs +2 -0
- package/dist/cjs/cli/index.cjs +1 -0
- package/dist/cjs/codecs/index.cjs +1 -0
- package/dist/cjs/coercion/index.cjs +1 -0
- package/dist/cjs/compat/emitter.cjs +1 -0
- package/dist/cjs/compat/result.cjs +1 -0
- package/dist/cjs/errors.cjs +1 -387
- package/dist/cjs/index.cjs +1 -10759
- package/dist/cjs/kernel.cjs +1 -0
- package/dist/cjs/locales/af.cjs +1 -0
- package/dist/cjs/locales/ar.cjs +1 -0
- package/dist/cjs/locales/bn.cjs +1 -0
- package/dist/cjs/locales/da.cjs +1 -0
- package/dist/cjs/locales/de.cjs +1 -0
- package/dist/cjs/locales/en.cjs +1 -0
- package/dist/cjs/locales/es-MX.cjs +1 -0
- package/dist/cjs/locales/es.cjs +1 -0
- package/dist/cjs/locales/fi.cjs +1 -0
- package/dist/cjs/locales/fr.cjs +1 -0
- package/dist/cjs/locales/hi.cjs +1 -0
- package/dist/cjs/locales/id.cjs +1 -0
- package/dist/cjs/locales/index.cjs +1 -2877
- package/dist/cjs/locales/it.cjs +1 -0
- package/dist/cjs/locales/ja.cjs +1 -0
- package/dist/cjs/locales/ko.cjs +1 -0
- package/dist/cjs/locales/lazy.cjs +1 -3169
- package/dist/cjs/locales/nl.cjs +1 -0
- package/dist/cjs/locales/no.cjs +1 -0
- package/dist/cjs/locales/pl.cjs +1 -0
- package/dist/cjs/locales/pt-BR.cjs +1 -0
- package/dist/cjs/locales/pt.cjs +1 -0
- package/dist/cjs/locales/ru.cjs +1 -0
- package/dist/cjs/locales/runtime.cjs +1 -0
- package/dist/cjs/locales/sv.cjs +1 -0
- package/dist/cjs/locales/sw.cjs +1 -0
- package/dist/cjs/locales/th.cjs +1 -0
- package/dist/cjs/locales/tr.cjs +1 -0
- package/dist/cjs/locales/vi.cjs +1 -0
- package/dist/cjs/locales/zh.cjs +1 -0
- package/dist/cjs/mini.cjs +1 -7474
- package/dist/cjs/pigment.cjs +1 -0
- package/dist/cjs/plugins/index.cjs +1 -0
- package/dist/cjs/registry.cjs +1 -0
- package/dist/cjs/v3/index.cjs +1 -0
- package/dist/cjs/v4/core/index.cjs +1 -0
- package/dist/cjs/v4/index.cjs +1 -0
- package/dist/cjs/v4/locales/index.cjs +1 -0
- package/dist/cjs/v4/mini/index.cjs +1 -0
- package/dist/cjs/v4-mini/index.cjs +1 -0
- package/dist/cjs/validators/any.cjs +1 -0
- package/dist/cjs/validators/array.cjs +1 -0
- package/dist/cjs/validators/base.cjs +1 -0
- package/dist/cjs/validators/base64.cjs +1 -0
- package/dist/cjs/validators/bigint.cjs +1 -0
- package/dist/cjs/validators/boolean.cjs +1 -0
- package/dist/cjs/validators/codec.cjs +1 -0
- package/dist/cjs/validators/custom.cjs +1 -0
- package/dist/cjs/validators/date.cjs +1 -0
- package/dist/cjs/validators/discriminated-union.cjs +1 -0
- package/dist/cjs/validators/enum.cjs +1 -0
- package/dist/cjs/validators/file.cjs +1 -0
- package/dist/cjs/validators/function.cjs +1 -0
- package/dist/cjs/validators/hex.cjs +1 -0
- package/dist/cjs/validators/index.cjs +1 -0
- package/dist/cjs/validators/intersection.cjs +1 -0
- package/dist/cjs/validators/json.cjs +1 -0
- package/dist/cjs/validators/lazy.cjs +1 -0
- package/dist/cjs/validators/literal.cjs +1 -0
- package/dist/cjs/validators/map.cjs +1 -0
- package/dist/cjs/validators/nan.cjs +1 -0
- package/dist/cjs/validators/never.cjs +1 -0
- package/dist/cjs/validators/null.cjs +1 -0
- package/dist/cjs/validators/number.cjs +1 -0
- package/dist/cjs/validators/object.cjs +1 -0
- package/dist/cjs/validators/promise.cjs +1 -0
- package/dist/cjs/validators/record.cjs +1 -0
- package/dist/cjs/validators/set.cjs +1 -0
- package/dist/cjs/validators/string-bool.cjs +1 -0
- package/dist/cjs/validators/string-formats.cjs +1 -0
- package/dist/cjs/validators/string.cjs +1 -0
- package/dist/cjs/validators/symbol.cjs +1 -0
- package/dist/cjs/validators/template-literal.cjs +1 -0
- package/dist/cjs/validators/tuple.cjs +1 -0
- package/dist/cjs/validators/uint8array.cjs +1 -0
- package/dist/cjs/validators/undefined.cjs +1 -0
- package/dist/cjs/validators/union.cjs +1 -0
- package/dist/cjs/validators/unknown.cjs +1 -0
- package/dist/cjs/validators/void.cjs +1 -0
- package/dist/cjs/validators/xor.cjs +1 -0
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +2 -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 +1 -0
- package/dist/codecs/index.d.ts +21 -4
- package/dist/codecs/index.js +1 -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 +1 -111
- 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 +1 -181
- package/dist/compat/index.d.ts +4 -5
- package/dist/compat/result.d.ts +1 -2
- package/dist/compat/result.js +1 -171
- package/dist/errors-core.d.ts +58 -0
- package/dist/errors.d.ts +4 -54
- package/dist/errors.js +1 -235
- package/dist/events.d.ts +3 -4
- package/dist/index.d.ts +1093 -851
- package/dist/index.js +1 -855
- package/dist/kernel.d.ts +2 -3
- package/dist/kernel.js +1 -405
- package/dist/locales/af.d.ts +1 -2
- package/dist/locales/af.js +1 -107
- package/dist/locales/ar.d.ts +1 -2
- package/dist/locales/ar.js +1 -107
- package/dist/locales/bn.d.ts +1 -2
- package/dist/locales/bn.js +1 -107
- package/dist/locales/da.d.ts +1 -2
- package/dist/locales/da.js +1 -107
- package/dist/locales/de.d.ts +1 -2
- package/dist/locales/de.js +1 -107
- package/dist/locales/en.d.ts +1 -2
- package/dist/locales/en.js +1 -107
- package/dist/locales/es-MX.d.ts +1 -2
- package/dist/locales/es-MX.js +1 -106
- package/dist/locales/es.d.ts +1 -2
- package/dist/locales/es.js +1 -95
- package/dist/locales/fi.d.ts +1 -2
- package/dist/locales/fi.js +1 -107
- package/dist/locales/fr.d.ts +1 -2
- package/dist/locales/fr.js +1 -95
- package/dist/locales/hi.d.ts +1 -2
- package/dist/locales/hi.js +1 -107
- package/dist/locales/id.d.ts +1 -2
- package/dist/locales/id.js +1 -107
- package/dist/locales/index.d.ts +10 -15
- package/dist/locales/index.js +1 -3
- package/dist/locales/it.d.ts +1 -2
- package/dist/locales/it.js +1 -107
- package/dist/locales/ja.d.ts +1 -2
- package/dist/locales/ja.js +1 -107
- package/dist/locales/ko.d.ts +1 -2
- package/dist/locales/ko.js +1 -107
- package/dist/locales/lazy.d.ts +4 -26
- package/dist/locales/lazy.js +1 -220
- package/dist/locales/nl.d.ts +1 -2
- package/dist/locales/nl.js +1 -107
- package/dist/locales/no.d.ts +1 -2
- package/dist/locales/no.js +1 -107
- package/dist/locales/pl.d.ts +1 -2
- package/dist/locales/pl.js +1 -107
- package/dist/locales/pt-BR.d.ts +1 -2
- package/dist/locales/pt-BR.js +1 -107
- package/dist/locales/pt.d.ts +1 -2
- package/dist/locales/pt.js +1 -107
- package/dist/locales/ru.d.ts +1 -2
- package/dist/locales/ru.js +1 -107
- package/dist/locales/runtime.d.ts +10 -0
- package/dist/locales/runtime.js +1 -0
- package/dist/locales/sv.d.ts +1 -2
- package/dist/locales/sv.js +1 -107
- package/dist/locales/sw.d.ts +1 -2
- package/dist/locales/sw.js +1 -107
- package/dist/locales/th.d.ts +1 -2
- package/dist/locales/th.js +1 -107
- package/dist/locales/tr.d.ts +1 -2
- package/dist/locales/tr.js +1 -107
- package/dist/locales/types.d.ts +0 -1
- package/dist/locales/vi.d.ts +1 -2
- package/dist/locales/vi.js +1 -107
- package/dist/locales/zh.d.ts +1 -2
- package/dist/locales/zh.js +1 -107
- package/dist/logger.d.ts +0 -1
- package/dist/mini.d.ts +67 -68
- package/dist/mini.js +1 -132
- package/dist/pigment.d.ts +0 -1
- package/dist/pigment.js +1 -178
- 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 +1 -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 +26 -7
- package/dist/utils/security.d.ts +2 -6
- package/dist/v3/index.d.ts +2 -0
- package/dist/v3/index.js +1 -0
- package/dist/v4/core/index.d.ts +272 -0
- package/dist/v4/core/index.js +1 -0
- package/dist/v4/index.d.ts +4 -0
- package/dist/v4/index.js +1 -0
- package/dist/v4/locales/index.d.ts +57 -0
- package/dist/v4/locales/index.js +1 -0
- package/dist/v4/mini/index.d.ts +2 -0
- package/dist/v4/mini/index.js +1 -0
- package/dist/v4-mini/index.d.ts +22 -0
- package/dist/v4-mini/index.js +1 -0
- package/dist/validators/any.d.ts +7 -2
- package/dist/validators/any.js +1 -0
- package/dist/validators/array.d.ts +16 -2
- package/dist/validators/array.js +1 -0
- package/dist/validators/base.d.ts +213 -14
- package/dist/validators/base.js +1 -0
- package/dist/validators/base64.d.ts +1 -2
- package/dist/validators/base64.js +1 -0
- package/dist/validators/bigint.d.ts +21 -3
- package/dist/validators/bigint.js +1 -0
- package/dist/validators/boolean.d.ts +13 -4
- package/dist/validators/boolean.js +1 -0
- package/dist/validators/codec.d.ts +9 -2
- package/dist/validators/codec.js +1 -0
- package/dist/validators/custom.d.ts +15 -2
- package/dist/validators/custom.js +1 -0
- package/dist/validators/date.d.ts +19 -3
- package/dist/validators/date.js +1 -0
- package/dist/validators/discriminated-union.d.ts +6 -5
- package/dist/validators/discriminated-union.js +1 -0
- package/dist/validators/enum.d.ts +10 -7
- package/dist/validators/enum.js +1 -0
- package/dist/validators/file.d.ts +7 -2
- package/dist/validators/file.js +1 -0
- package/dist/validators/function.d.ts +11 -5
- package/dist/validators/function.js +1 -0
- package/dist/validators/hex.d.ts +1 -2
- package/dist/validators/hex.js +1 -0
- package/dist/validators/index.d.ts +38 -39
- package/dist/validators/index.js +1 -515
- package/dist/validators/intersection.d.ts +1 -2
- package/dist/validators/intersection.js +1 -0
- package/dist/validators/json.d.ts +1 -2
- package/dist/validators/json.js +1 -0
- package/dist/validators/lazy.d.ts +5 -9
- package/dist/validators/lazy.js +1 -0
- package/dist/validators/literal.d.ts +9 -5
- package/dist/validators/literal.js +1 -0
- package/dist/validators/map.d.ts +15 -2
- package/dist/validators/map.js +1 -0
- package/dist/validators/nan.d.ts +2 -3
- package/dist/validators/nan.js +1 -0
- package/dist/validators/never.d.ts +1 -2
- package/dist/validators/never.js +1 -0
- package/dist/validators/null.d.ts +3 -3
- package/dist/validators/null.js +1 -0
- package/dist/validators/number.d.ts +75 -27
- package/dist/validators/number.js +1 -0
- package/dist/validators/object.d.ts +42 -11
- package/dist/validators/object.js +1 -0
- package/dist/validators/promise.d.ts +15 -10
- package/dist/validators/promise.js +1 -0
- package/dist/validators/record.d.ts +21 -9
- package/dist/validators/record.js +1 -0
- package/dist/validators/set.d.ts +11 -2
- package/dist/validators/set.js +1 -0
- package/dist/validators/string-bool.d.ts +7 -10
- package/dist/validators/string-bool.js +1 -0
- package/dist/validators/string-formats.d.ts +64 -65
- package/dist/validators/string-formats.js +1 -0
- package/dist/validators/string.d.ts +84 -26
- package/dist/validators/string.js +1 -0
- package/dist/validators/symbol.d.ts +8 -3
- package/dist/validators/symbol.js +1 -0
- package/dist/validators/template-literal.d.ts +1 -2
- package/dist/validators/template-literal.js +1 -0
- package/dist/validators/tuple.d.ts +29 -12
- package/dist/validators/tuple.js +1 -0
- package/dist/validators/uint8array.d.ts +3 -4
- package/dist/validators/uint8array.js +1 -0
- package/dist/validators/undefined.d.ts +3 -3
- package/dist/validators/undefined.js +1 -0
- package/dist/validators/union.d.ts +7 -4
- package/dist/validators/union.js +1 -0
- package/dist/validators/unknown.d.ts +7 -2
- package/dist/validators/unknown.js +1 -0
- package/dist/validators/void.d.ts +3 -2
- package/dist/validators/void.js +1 -0
- package/dist/validators/xor.d.ts +4 -5
- package/dist/validators/xor.js +1 -0
- package/package.json +239 -154
- package/dist/chunks/bigint-CRS0QVsy.js +0 -1854
- package/dist/chunks/bigint-CRS0QVsy.js.map +0 -1
- package/dist/chunks/date-50JV_Mfj.js +0 -506
- package/dist/chunks/date-50JV_Mfj.js.map +0 -1
- package/dist/chunks/index-DO8CFMxD.js +0 -894
- 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 +0 -28
- 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
package/dist/index.js
CHANGED
|
@@ -1,855 +1 @@
|
|
|
1
|
-
import { g as VldPreprocess, r as VldExactOptional, e as VldNullish, d as VldNullable, f as VldOptional, V as VldBigInt, b as VldDate, a as VldBoolean, c as VldNumber, h as VldString } from './chunks/bigint-CRS0QVsy.js';
|
|
2
|
-
export { i as VldBase, s as VldMeta, t as getLocale, u as getMessages, v as setLocale } from './chunks/bigint-CRS0QVsy.js';
|
|
3
|
-
import { f as VldJson, g as VldLazy, V as VldNever, l as VldNan, r as VldUndefined, m as VldNull, t as VldVoid, a as VldAny, d as VldEnum, h as VldLiteral, u as VldXor, c as VldDiscriminatedUnion, e as VldIntersection, s as VldUnion, k as VldMap, n as VldSet, j as VldRecord, q as VldTuple, i as VldObject, b as VldArray, o as VldStringBool, p as VldSymbol } from './chunks/json-Cp4WO0M9.js';
|
|
4
|
-
import { V as VldUnknown } from './chunks/unknown-Dhzri_T-.js';
|
|
5
|
-
import { promise, templateLiteral, httpUrl, guid, xid, stringFormat, iso, hash, e164, cidrv6, cidrv4, mac, ipv6, ipv4, ulid, cuid2, cuid, nanoid, jwt, hex, base64url, base64, emoji, hostname, uuidv4, uuid, email, functionValidator, file, custom } from './validators/index.js';
|
|
6
|
-
import { V as VldCodec, a as VldUint8Array, b as VldHex, c as VldBase64 } from './chunks/index-DO8CFMxD.js';
|
|
7
|
-
export { d as base64Json, e as base64ToBytes, f as base64ToUint8Array, g as base64UrlToBytes, h as base64urlToBytes, i as bytesToUtf8, j as epochMillisToDate, k as epochSecondsToDate, l as hexLowerToBytes, m as hexToBytes, n as hexToUint8Array, o as isoDatetimeToDate, p as jsonCodec, q as jwtPayload, r as numberToBigInt, s as stringToBigInt, t as stringToBoolean, u as stringToHttpURL, v as stringToInt, w as stringToNumber, x as stringToURL, y as stringToUint8Array, z as uint8ArrayToBase64, A as uint8ArrayToBase64Url, B as uint8ArrayToHex, C as uint8ArrayToString, D as uriComponent, E as utf8ToBytes } from './chunks/index-DO8CFMxD.js';
|
|
8
|
-
import { V as VldCoerceDate, a as VldCoerceBoolean, b as VldCoerceNumber, c as VldCoerceString } from './chunks/date-50JV_Mfj.js';
|
|
9
|
-
import { VldCoerceBigInt } from './coercion/index.js';
|
|
10
|
-
export { VldError, flattenError, prettifyError, prettifyErrorColored, prettifyErrorPlain, treeifyError } from './errors.js';
|
|
11
|
-
export { Err, Ok, ResultUtils, all, failure, flatMap, fromNullable, isErr, isOk, isResult, map, mapErr, match, success, tryCatch, tryCatchAsync, unwrap, unwrapOr } from './compat/result.js';
|
|
12
|
-
export { createEmitter, createEventBus, withEmitter } from './compat/emitter.js';
|
|
13
|
-
export { createVldKernel, definePlugin, getVldKernel, resetVldKernel, usePlugin } from './kernel.js';
|
|
14
|
-
export { blue, bold, createTheme, cyan, dim, gray, green, grey, italic, magenta, default as pigment, red, strip, supportsColor, underline, vldTheme, white, yellow } from './pigment.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* VLD Logger
|
|
18
|
-
*
|
|
19
|
-
* This module provides a debug logging system for VLD,
|
|
20
|
-
* compatible with @oxog/log when available.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Log level priorities (lower = more verbose)
|
|
24
|
-
*/
|
|
25
|
-
const LOG_LEVEL_PRIORITY = {
|
|
26
|
-
debug: 0,
|
|
27
|
-
info: 1,
|
|
28
|
-
warn: 2,
|
|
29
|
-
error: 3,
|
|
30
|
-
silent: 4
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* ANSI color codes for terminal output
|
|
34
|
-
*/
|
|
35
|
-
const COLORS = {
|
|
36
|
-
reset: '\x1b[0m',
|
|
37
|
-
dim: '\x1b[2m',
|
|
38
|
-
red: '\x1b[31m',
|
|
39
|
-
yellow: '\x1b[33m',
|
|
40
|
-
blue: '\x1b[34m',
|
|
41
|
-
cyan: '\x1b[36m',
|
|
42
|
-
gray: '\x1b[90m'
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Level colors
|
|
46
|
-
*/
|
|
47
|
-
const LEVEL_COLORS = {
|
|
48
|
-
debug: COLORS.gray,
|
|
49
|
-
info: COLORS.blue,
|
|
50
|
-
warn: COLORS.yellow,
|
|
51
|
-
error: COLORS.red
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Level labels
|
|
55
|
-
*/
|
|
56
|
-
const LEVEL_LABELS = {
|
|
57
|
-
debug: 'DEBUG',
|
|
58
|
-
info: 'INFO ',
|
|
59
|
-
warn: 'WARN ',
|
|
60
|
-
error: 'ERROR'
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Default log handler
|
|
64
|
-
*/
|
|
65
|
-
function createDefaultHandler(options) {
|
|
66
|
-
const colored = options.colored ?? true;
|
|
67
|
-
const timestamps = options.timestamps ?? true;
|
|
68
|
-
return (entry) => {
|
|
69
|
-
const parts = [];
|
|
70
|
-
// Timestamp
|
|
71
|
-
if (timestamps) {
|
|
72
|
-
const time = entry.timestamp.toISOString().slice(11, 23);
|
|
73
|
-
parts.push(colored ? `${COLORS.dim}${time}${COLORS.reset}` : time);
|
|
74
|
-
}
|
|
75
|
-
// Level
|
|
76
|
-
const levelLabel = LEVEL_LABELS[entry.level];
|
|
77
|
-
const levelColor = LEVEL_COLORS[entry.level];
|
|
78
|
-
parts.push(colored ? `${levelColor}${levelLabel}${COLORS.reset}` : levelLabel);
|
|
79
|
-
// Name
|
|
80
|
-
parts.push(colored ? `${COLORS.cyan}[${entry.name}]${COLORS.reset}` : `[${entry.name}]`);
|
|
81
|
-
// Message
|
|
82
|
-
parts.push(entry.message);
|
|
83
|
-
// Output
|
|
84
|
-
const output = parts.join(' ');
|
|
85
|
-
// Use appropriate console method
|
|
86
|
-
switch (entry.level) {
|
|
87
|
-
case 'debug':
|
|
88
|
-
console.debug(output, entry.data !== undefined ? entry.data : '');
|
|
89
|
-
break;
|
|
90
|
-
case 'info':
|
|
91
|
-
console.info(output, entry.data !== undefined ? entry.data : '');
|
|
92
|
-
break;
|
|
93
|
-
case 'warn':
|
|
94
|
-
console.warn(output, entry.data !== undefined ? entry.data : '');
|
|
95
|
-
break;
|
|
96
|
-
case 'error':
|
|
97
|
-
console.error(output, entry.data !== undefined ? entry.data : '');
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Create a logger instance
|
|
104
|
-
*/
|
|
105
|
-
function createLogger(options = {}) {
|
|
106
|
-
const name = options.name ?? 'vld';
|
|
107
|
-
let level = options.level ?? 'warn';
|
|
108
|
-
const handler = options.handler ?? createDefaultHandler(options);
|
|
109
|
-
const log = (logLevel, message, data) => {
|
|
110
|
-
if (LOG_LEVEL_PRIORITY[logLevel] < LOG_LEVEL_PRIORITY[level]) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const entry = {
|
|
114
|
-
level: logLevel,
|
|
115
|
-
message,
|
|
116
|
-
data,
|
|
117
|
-
timestamp: new Date(),
|
|
118
|
-
name
|
|
119
|
-
};
|
|
120
|
-
handler(entry);
|
|
121
|
-
};
|
|
122
|
-
const logger = {
|
|
123
|
-
debug: (message, data) => log('debug', message, data),
|
|
124
|
-
info: (message, data) => log('info', message, data),
|
|
125
|
-
warn: (message, data) => log('warn', message, data),
|
|
126
|
-
error: (message, data) => log('error', message, data),
|
|
127
|
-
isLevelEnabled: (checkLevel) => LOG_LEVEL_PRIORITY[checkLevel] >= LOG_LEVEL_PRIORITY[level],
|
|
128
|
-
setLevel: (newLevel) => {
|
|
129
|
-
level = newLevel;
|
|
130
|
-
},
|
|
131
|
-
getLevel: () => level,
|
|
132
|
-
child: (childName) => createLogger({
|
|
133
|
-
...options,
|
|
134
|
-
name: `${name}:${childName}`
|
|
135
|
-
})
|
|
136
|
-
};
|
|
137
|
-
return logger;
|
|
138
|
-
}
|
|
139
|
-
// ============================================
|
|
140
|
-
// Global Logger Management
|
|
141
|
-
// ============================================
|
|
142
|
-
let globalLogger = null;
|
|
143
|
-
/**
|
|
144
|
-
* Initialize the global VLD logger
|
|
145
|
-
*/
|
|
146
|
-
function initLogger(options) {
|
|
147
|
-
globalLogger = createLogger({
|
|
148
|
-
name: 'vld',
|
|
149
|
-
...options
|
|
150
|
-
});
|
|
151
|
-
return globalLogger;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Get the global VLD logger
|
|
155
|
-
* Returns null if not initialized
|
|
156
|
-
*/
|
|
157
|
-
function getLogger() {
|
|
158
|
-
return globalLogger;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Set log level for the global logger
|
|
162
|
-
*/
|
|
163
|
-
function setLogLevel(level) {
|
|
164
|
-
if (globalLogger) {
|
|
165
|
-
globalLogger.setLevel(level);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Enable debug mode for VLD
|
|
170
|
-
*/
|
|
171
|
-
function enableDebug() {
|
|
172
|
-
if (!globalLogger) {
|
|
173
|
-
initLogger({ level: 'debug' });
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
globalLogger.setLevel('debug');
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Disable all VLD logging
|
|
181
|
-
*/
|
|
182
|
-
function disableLogging() {
|
|
183
|
-
if (globalLogger) {
|
|
184
|
-
globalLogger.setLevel('silent');
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Create a no-op logger for testing
|
|
189
|
-
*/
|
|
190
|
-
function createNoOpLogger() {
|
|
191
|
-
return createLogger({ level: 'silent' });
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* JSON Schema support for VLD validators
|
|
196
|
-
* Provides conversion between VLD schemas and JSON Schema
|
|
197
|
-
*/
|
|
198
|
-
/**
|
|
199
|
-
* Convert a VLD schema to JSON Schema
|
|
200
|
-
* @param schema The VLD schema to convert
|
|
201
|
-
* @param options Conversion options
|
|
202
|
-
* @returns JSON Schema definition
|
|
203
|
-
*/
|
|
204
|
-
function toJSONSchema(schema, options = {}) {
|
|
205
|
-
return schemaToJSONSchema(schema, options);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Convert a JSON Schema to a VLD schema
|
|
209
|
-
* @param json The JSON Schema definition
|
|
210
|
-
* @returns A VLD schema
|
|
211
|
-
*/
|
|
212
|
-
function fromJSONSchema(json) {
|
|
213
|
-
return jsonSchemaToVLD(json);
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Internal function to convert VLD schema to JSON Schema
|
|
217
|
-
*/
|
|
218
|
-
function schemaToJSONSchema(schema, options) {
|
|
219
|
-
// Handle primitives
|
|
220
|
-
if (schema.constructor.name === 'VldString') {
|
|
221
|
-
return buildStringSchema();
|
|
222
|
-
}
|
|
223
|
-
if (schema.constructor.name === 'VldNumber') {
|
|
224
|
-
return buildNumberSchema(schema);
|
|
225
|
-
}
|
|
226
|
-
if (schema.constructor.name === 'VldBoolean') {
|
|
227
|
-
return { type: 'boolean' };
|
|
228
|
-
}
|
|
229
|
-
if (schema.constructor.name === 'VldBigInt') {
|
|
230
|
-
return { type: 'integer' };
|
|
231
|
-
}
|
|
232
|
-
if (schema.constructor.name === 'VldDate') {
|
|
233
|
-
return { type: 'string', format: 'date-time' };
|
|
234
|
-
}
|
|
235
|
-
if (schema.constructor.name === 'VldArray') {
|
|
236
|
-
return buildArraySchema(schema, options);
|
|
237
|
-
}
|
|
238
|
-
if (schema.constructor.name === 'VldObject') {
|
|
239
|
-
return buildObjectSchema(schema, options);
|
|
240
|
-
}
|
|
241
|
-
// Handle union types
|
|
242
|
-
if (schema.constructor.name === 'VldUnion') {
|
|
243
|
-
return buildUnionSchema(schema, options);
|
|
244
|
-
}
|
|
245
|
-
// Handle literal types
|
|
246
|
-
if (schema.constructor.name === 'VldLiteral') {
|
|
247
|
-
return buildLiteralSchema(schema);
|
|
248
|
-
}
|
|
249
|
-
if (schema.constructor.name === 'VldEnum') {
|
|
250
|
-
return buildEnumSchema(schema);
|
|
251
|
-
}
|
|
252
|
-
if (schema.constructor.name === 'VldRecord') {
|
|
253
|
-
return buildRecordSchema(schema, options);
|
|
254
|
-
}
|
|
255
|
-
if (schema.constructor.name === 'VldTuple') {
|
|
256
|
-
return buildTupleSchema(schema, options);
|
|
257
|
-
}
|
|
258
|
-
if (schema.constructor.name === 'VldIntersection') {
|
|
259
|
-
return buildIntersectionSchema(schema, options);
|
|
260
|
-
}
|
|
261
|
-
if (schema.constructor.name === 'VldOptional') {
|
|
262
|
-
return buildOptionalSchema(schema, options);
|
|
263
|
-
}
|
|
264
|
-
if (schema.constructor.name === 'VldNullable') {
|
|
265
|
-
return buildNullableSchema(schema, options);
|
|
266
|
-
}
|
|
267
|
-
if (schema.constructor.name === 'VldNullish') {
|
|
268
|
-
return buildNullishSchema(schema, options);
|
|
269
|
-
}
|
|
270
|
-
if (schema.constructor.name === 'VldExactOptional') {
|
|
271
|
-
return buildExactOptionalSchema(schema, options);
|
|
272
|
-
}
|
|
273
|
-
if (schema.constructor.name === 'VldLazy') {
|
|
274
|
-
return { type: 'object' }; // Placeholder for recursive schemas
|
|
275
|
-
}
|
|
276
|
-
if (schema.constructor.name === 'VldJson') {
|
|
277
|
-
return {}; // Any JSON
|
|
278
|
-
}
|
|
279
|
-
if (schema.constructor.name === 'VldAny') {
|
|
280
|
-
return {}; // JSON Schema true
|
|
281
|
-
}
|
|
282
|
-
if (schema.constructor.name === 'VldUnknown') {
|
|
283
|
-
return {}; // JSON Schema true
|
|
284
|
-
}
|
|
285
|
-
if (schema.constructor.name === 'VldNever') {
|
|
286
|
-
return { not: {} }; // JSON Schema false
|
|
287
|
-
}
|
|
288
|
-
if (schema.constructor.name === 'VldNull') {
|
|
289
|
-
return { type: 'null' };
|
|
290
|
-
}
|
|
291
|
-
if (schema.constructor.name === 'VldUndefined') {
|
|
292
|
-
return { not: {} }; // Undefined can't be represented in JSON Schema
|
|
293
|
-
}
|
|
294
|
-
if (schema.constructor.name === 'VldNan') {
|
|
295
|
-
return { type: 'number', not: {} }; // NaN is a number type constraint
|
|
296
|
-
}
|
|
297
|
-
if (schema.constructor.name === 'VldVoid') {
|
|
298
|
-
return { not: {} }; // Void/undefined can't be represented
|
|
299
|
-
}
|
|
300
|
-
// Handle branded types - unwrap and continue
|
|
301
|
-
if (schema.constructor.name === 'VldBrand') {
|
|
302
|
-
return schemaToJSONSchema(schema.baseValidator, options);
|
|
303
|
-
}
|
|
304
|
-
// Handle readonly types
|
|
305
|
-
if (schema.constructor.name === 'VldReadonly') {
|
|
306
|
-
return schemaToJSONSchema(schema.baseValidator, options);
|
|
307
|
-
}
|
|
308
|
-
// Handle transform types
|
|
309
|
-
if (schema.constructor.name === 'VldTransform') {
|
|
310
|
-
return schemaToJSONSchema(schema._inner, options);
|
|
311
|
-
}
|
|
312
|
-
// Handle meta types - unwrap metadata
|
|
313
|
-
if (schema.constructor.name === 'VldMeta') {
|
|
314
|
-
const metaSchema = schema;
|
|
315
|
-
const result = schemaToJSONSchema(metaSchema.baseValidator, options);
|
|
316
|
-
if (options.includeMetadata !== false && metaSchema.metadata) {
|
|
317
|
-
const meta = metaSchema.metadata;
|
|
318
|
-
if (meta.title)
|
|
319
|
-
result.title = meta.title;
|
|
320
|
-
if (meta.description)
|
|
321
|
-
result.description = meta.description;
|
|
322
|
-
if (meta.examples && options.includeExamples)
|
|
323
|
-
result.examples = meta.examples;
|
|
324
|
-
if (meta.default !== undefined)
|
|
325
|
-
result.default = meta.default;
|
|
326
|
-
if (meta.deprecated)
|
|
327
|
-
result.deprecated = true;
|
|
328
|
-
if (meta.readOnly)
|
|
329
|
-
result.readOnly = true;
|
|
330
|
-
if (meta.writeOnly)
|
|
331
|
-
result.writeOnly = true;
|
|
332
|
-
}
|
|
333
|
-
return result;
|
|
334
|
-
}
|
|
335
|
-
// Handle refine/superRefine types
|
|
336
|
-
if (schema.constructor.name === 'VldRefine' || schema.constructor.name === 'VldSuperRefine') {
|
|
337
|
-
return schemaToJSONSchema(schema._inner || schema._baseValidator, options);
|
|
338
|
-
}
|
|
339
|
-
// Handle pipe types
|
|
340
|
-
if (schema.constructor.name === 'VldPipe') {
|
|
341
|
-
return schemaToJSONSchema(schema._next || schema.second, options);
|
|
342
|
-
}
|
|
343
|
-
// Handle default/catch types
|
|
344
|
-
if (schema.constructor.name === 'VldDefault' || schema.constructor.name === 'VldCatch') {
|
|
345
|
-
return schemaToJSONSchema(schema._inner || schema._baseValidator, options);
|
|
346
|
-
}
|
|
347
|
-
// Handle preprocess types
|
|
348
|
-
if (schema.constructor.name === 'VldPreprocess') {
|
|
349
|
-
return schemaToJSONSchema(schema._schema, options);
|
|
350
|
-
}
|
|
351
|
-
// Handle string format validators
|
|
352
|
-
if (schema.constructor.name === 'VldStringFormat') {
|
|
353
|
-
const formatSchema = schema;
|
|
354
|
-
return { type: 'string', format: formatSchema._format };
|
|
355
|
-
}
|
|
356
|
-
// Fallback for unknown types
|
|
357
|
-
return {};
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Build string JSON Schema
|
|
361
|
-
*/
|
|
362
|
-
function buildStringSchema(_target) {
|
|
363
|
-
return { type: 'string' };
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Build number JSON Schema from VLD number schema
|
|
367
|
-
*/
|
|
368
|
-
function buildNumberSchema(schema, _target) {
|
|
369
|
-
const config = schema.config || {};
|
|
370
|
-
const checks = config.checks || [];
|
|
371
|
-
const result = { type: 'number' };
|
|
372
|
-
for (const check of checks) {
|
|
373
|
-
// Try to extract constraints from closures
|
|
374
|
-
const checkStr = check.toString();
|
|
375
|
-
if (checkStr.includes('>=') || checkStr.includes('min')) {
|
|
376
|
-
result.minimum = 0; // Default, actual value is in closure
|
|
377
|
-
}
|
|
378
|
-
if (checkStr.includes('<=') || checkStr.includes('max')) {
|
|
379
|
-
result.maximum = 0; // Default, actual value is in closure
|
|
380
|
-
}
|
|
381
|
-
if (checkStr.includes('isInteger') || checkStr.includes('int')) {
|
|
382
|
-
result.type = 'integer';
|
|
383
|
-
}
|
|
384
|
-
if (checkStr.includes('isSafeInteger')) {
|
|
385
|
-
result.type = 'integer';
|
|
386
|
-
}
|
|
387
|
-
if (checkStr.includes('Number.isFinite')) ;
|
|
388
|
-
}
|
|
389
|
-
return result;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Build array JSON Schema
|
|
393
|
-
*/
|
|
394
|
-
function buildArraySchema(schema, options) {
|
|
395
|
-
const inner = schema._item || schema._inner;
|
|
396
|
-
if (inner) {
|
|
397
|
-
return {
|
|
398
|
-
type: 'array',
|
|
399
|
-
items: toJSONSchema(inner, options)
|
|
400
|
-
};
|
|
401
|
-
}
|
|
402
|
-
return { type: 'array' };
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Build object JSON Schema
|
|
406
|
-
*/
|
|
407
|
-
function buildObjectSchema(schema, options) {
|
|
408
|
-
const shape = schema._shape || schema.shape;
|
|
409
|
-
if (!shape)
|
|
410
|
-
return { type: 'object' };
|
|
411
|
-
const properties = {};
|
|
412
|
-
const required = [];
|
|
413
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
414
|
-
properties[key] = toJSONSchema(value, options);
|
|
415
|
-
// VLD objects require all keys by default
|
|
416
|
-
if (schema._strict !== false) {
|
|
417
|
-
required.push(key);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
const result = {
|
|
421
|
-
type: 'object',
|
|
422
|
-
properties
|
|
423
|
-
};
|
|
424
|
-
if (required.length > 0) {
|
|
425
|
-
result.required = required;
|
|
426
|
-
}
|
|
427
|
-
// Handle passthrough mode
|
|
428
|
-
if (schema._passthrough || schema._loose) {
|
|
429
|
-
result.additionalProperties = true;
|
|
430
|
-
}
|
|
431
|
-
else if (schema._strict) {
|
|
432
|
-
result.additionalProperties = false;
|
|
433
|
-
}
|
|
434
|
-
return result;
|
|
435
|
-
}
|
|
436
|
-
/**
|
|
437
|
-
* Build union JSON Schema
|
|
438
|
-
*/
|
|
439
|
-
function buildUnionSchema(schema, options) {
|
|
440
|
-
const validators = schema._validators || schema._options || [];
|
|
441
|
-
return {
|
|
442
|
-
anyOf: validators.map((v) => toJSONSchema(v, options))
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
|
-
/**
|
|
446
|
-
* Build literal JSON Schema
|
|
447
|
-
*/
|
|
448
|
-
function buildLiteralSchema(schema) {
|
|
449
|
-
const value = schema._value || schema.value;
|
|
450
|
-
if (value === null)
|
|
451
|
-
return { type: 'null' };
|
|
452
|
-
if (typeof value === 'string')
|
|
453
|
-
return { type: 'string', const: value };
|
|
454
|
-
if (typeof value === 'number')
|
|
455
|
-
return { type: 'number', const: value };
|
|
456
|
-
if (typeof value === 'boolean')
|
|
457
|
-
return { type: 'boolean', const: value };
|
|
458
|
-
return { const: value };
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Build enum JSON Schema
|
|
462
|
-
*/
|
|
463
|
-
function buildEnumSchema(schema) {
|
|
464
|
-
const values = schema._values || schema.values;
|
|
465
|
-
if (Array.isArray(values)) {
|
|
466
|
-
return { enum: [...values] };
|
|
467
|
-
}
|
|
468
|
-
return {};
|
|
469
|
-
}
|
|
470
|
-
/**
|
|
471
|
-
* Build record JSON Schema
|
|
472
|
-
*/
|
|
473
|
-
function buildRecordSchema(schema, options) {
|
|
474
|
-
const valueValidator = schema._value || schema._inner;
|
|
475
|
-
if (valueValidator) {
|
|
476
|
-
return {
|
|
477
|
-
type: 'object',
|
|
478
|
-
additionalProperties: toJSONSchema(valueValidator, options)
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
return { type: 'object' };
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Build tuple JSON Schema
|
|
485
|
-
*/
|
|
486
|
-
function buildTupleSchema(schema, options) {
|
|
487
|
-
const items = schema._items || schema.items;
|
|
488
|
-
if (!items || !Array.isArray(items)) {
|
|
489
|
-
return { type: 'array' };
|
|
490
|
-
}
|
|
491
|
-
return {
|
|
492
|
-
type: 'array',
|
|
493
|
-
items: items.map((item) => toJSONSchema(item, options)),
|
|
494
|
-
minItems: items.length,
|
|
495
|
-
maxItems: items.length
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Build intersection JSON Schema
|
|
500
|
-
*/
|
|
501
|
-
function buildIntersectionSchema(schema, options) {
|
|
502
|
-
const first = schema._first || schema.first;
|
|
503
|
-
const second = schema._second || schema.second;
|
|
504
|
-
const schemas = [];
|
|
505
|
-
if (first)
|
|
506
|
-
schemas.push(toJSONSchema(first, options));
|
|
507
|
-
if (second)
|
|
508
|
-
schemas.push(toJSONSchema(second, options));
|
|
509
|
-
if (schemas.length === 0)
|
|
510
|
-
return {};
|
|
511
|
-
if (schemas.length === 1)
|
|
512
|
-
return schemas[0];
|
|
513
|
-
return { allOf: schemas };
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Build optional JSON Schema
|
|
517
|
-
*/
|
|
518
|
-
function buildOptionalSchema(schema, options) {
|
|
519
|
-
const inner = schema._inner || schema._baseValidator;
|
|
520
|
-
if (!inner)
|
|
521
|
-
return {};
|
|
522
|
-
const result = toJSONSchema(inner, options);
|
|
523
|
-
// Remove from required array - but we don't track required here
|
|
524
|
-
return result;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Build nullable JSON Schema
|
|
528
|
-
*/
|
|
529
|
-
function buildNullableSchema(schema, options) {
|
|
530
|
-
const inner = schema._inner || schema._baseValidator;
|
|
531
|
-
if (!inner)
|
|
532
|
-
return { type: 'null' };
|
|
533
|
-
const result = toJSONSchema(inner, options);
|
|
534
|
-
if (typeof result.type === 'string') {
|
|
535
|
-
return { type: [result.type, 'null'] };
|
|
536
|
-
}
|
|
537
|
-
else if (Array.isArray(result.type)) {
|
|
538
|
-
result.type.push('null');
|
|
539
|
-
return result;
|
|
540
|
-
}
|
|
541
|
-
return {
|
|
542
|
-
anyOf: [result, { type: 'null' }]
|
|
543
|
-
};
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Build nullish JSON Schema
|
|
547
|
-
*/
|
|
548
|
-
function buildNullishSchema(schema, options) {
|
|
549
|
-
const inner = schema._inner || schema._baseValidator;
|
|
550
|
-
if (!inner)
|
|
551
|
-
return {};
|
|
552
|
-
return toJSONSchema(inner, options);
|
|
553
|
-
}
|
|
554
|
-
/**
|
|
555
|
-
* Build exactOptional JSON Schema
|
|
556
|
-
*/
|
|
557
|
-
function buildExactOptionalSchema(schema, options) {
|
|
558
|
-
const inner = schema._inner || schema._baseValidator;
|
|
559
|
-
if (!inner)
|
|
560
|
-
return {};
|
|
561
|
-
return toJSONSchema(inner, options);
|
|
562
|
-
}
|
|
563
|
-
/**
|
|
564
|
-
* Internal function to convert JSON Schema to VLD schema
|
|
565
|
-
*/
|
|
566
|
-
function jsonSchemaToVLD(json) {
|
|
567
|
-
// This is a simplified implementation
|
|
568
|
-
// Full implementation would recursively handle all JSON Schema types
|
|
569
|
-
const VldString = require('../validators/string').VldString;
|
|
570
|
-
const VldNumber = require('../validators/number').VldNumber;
|
|
571
|
-
const VldBoolean = require('../validators/boolean').VldBoolean;
|
|
572
|
-
const VldObject = require('../validators/object').VldObject;
|
|
573
|
-
const VldArray = require('../validators/array').VldArray;
|
|
574
|
-
const VldUnion = require('../validators/union').VldUnion;
|
|
575
|
-
const VldLiteral = require('../validators/literal').VldLiteral;
|
|
576
|
-
const VldEnum = require('../validators/enum').VldEnum;
|
|
577
|
-
const VldNull = require('../validators/null').VldNull;
|
|
578
|
-
const VldAny = require('../validators/any').VldAny;
|
|
579
|
-
const VldRecord = require('../validators/record').VldRecord;
|
|
580
|
-
// Handle $ref
|
|
581
|
-
if (json.$ref) {
|
|
582
|
-
// For now, return any - full $ref handling requires registry
|
|
583
|
-
return VldAny.create();
|
|
584
|
-
}
|
|
585
|
-
// Handle anyOf/oneOf (union)
|
|
586
|
-
if (json.anyOf || json.oneOf) {
|
|
587
|
-
const options = (json.anyOf || json.oneOf)
|
|
588
|
-
.map((s) => jsonSchemaToVLD(s))
|
|
589
|
-
.filter(Boolean);
|
|
590
|
-
if (options.length > 0) {
|
|
591
|
-
return VldUnion.create(...options);
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
// Handle allOf (intersection)
|
|
595
|
-
if (json.allOf) {
|
|
596
|
-
// For intersection, we'd need VldIntersection
|
|
597
|
-
const first = jsonSchemaToVLD(json.allOf[0]);
|
|
598
|
-
if (json.allOf.length > 1) {
|
|
599
|
-
const second = jsonSchemaToVLD({ allOf: json.allOf.slice(1) });
|
|
600
|
-
const VldIntersection = require('../validators/intersection').VldIntersection;
|
|
601
|
-
return VldIntersection.create(first, second);
|
|
602
|
-
}
|
|
603
|
-
return first;
|
|
604
|
-
}
|
|
605
|
-
// Handle not
|
|
606
|
-
if (json.not) {
|
|
607
|
-
// For negation, we need special handling
|
|
608
|
-
return VldAny.create();
|
|
609
|
-
}
|
|
610
|
-
// Handle const
|
|
611
|
-
if (json.const !== undefined) {
|
|
612
|
-
return VldLiteral.create(json.const);
|
|
613
|
-
}
|
|
614
|
-
// Handle enum
|
|
615
|
-
if (json.enum) {
|
|
616
|
-
return VldEnum.create(json.enum);
|
|
617
|
-
}
|
|
618
|
-
// Handle type
|
|
619
|
-
const type = json.type;
|
|
620
|
-
if (type === 'string' || type === undefined) {
|
|
621
|
-
const s = VldString.create();
|
|
622
|
-
if (json.minLength)
|
|
623
|
-
s.minLength = json.minLength;
|
|
624
|
-
if (json.maxLength)
|
|
625
|
-
s.maxLength = json.maxLength;
|
|
626
|
-
if (json.pattern)
|
|
627
|
-
s.pattern = json.pattern;
|
|
628
|
-
if (json.format) {
|
|
629
|
-
// Map JSON Schema formats to VLD validators
|
|
630
|
-
switch (json.format) {
|
|
631
|
-
case 'date-time':
|
|
632
|
-
case 'date':
|
|
633
|
-
case 'time':
|
|
634
|
-
// Would need DateTime validator
|
|
635
|
-
break;
|
|
636
|
-
case 'email':
|
|
637
|
-
const email = require('../validators/string-formats').email;
|
|
638
|
-
return email();
|
|
639
|
-
case 'uri':
|
|
640
|
-
case 'uri-reference':
|
|
641
|
-
const httpUrl = require('../validators/string-formats').httpUrl;
|
|
642
|
-
return httpUrl();
|
|
643
|
-
case 'uuid':
|
|
644
|
-
const uuid = require('../validators/string-formats').uuid;
|
|
645
|
-
return uuid();
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
return s;
|
|
649
|
-
}
|
|
650
|
-
if (type === 'number' || type === 'integer') {
|
|
651
|
-
const n = VldNumber.create();
|
|
652
|
-
if (type === 'integer')
|
|
653
|
-
n.int();
|
|
654
|
-
if (json.minimum !== undefined)
|
|
655
|
-
n.min(json.minimum);
|
|
656
|
-
if (json.maximum !== undefined)
|
|
657
|
-
n.max(json.maximum);
|
|
658
|
-
if (json.exclusiveMinimum !== undefined)
|
|
659
|
-
n.gt(json.exclusiveMinimum);
|
|
660
|
-
if (json.exclusiveMaximum !== undefined)
|
|
661
|
-
n.lt(json.exclusiveMaximum);
|
|
662
|
-
if (json.multipleOf !== undefined)
|
|
663
|
-
n.multipleOf(json.multipleOf);
|
|
664
|
-
return n;
|
|
665
|
-
}
|
|
666
|
-
if (type === 'boolean') {
|
|
667
|
-
return VldBoolean.create();
|
|
668
|
-
}
|
|
669
|
-
if (type === 'array') {
|
|
670
|
-
if (json.items && !Array.isArray(json.items)) {
|
|
671
|
-
return VldArray.create(jsonSchemaToVLD(json.items));
|
|
672
|
-
}
|
|
673
|
-
return VldArray.create(VldAny.create());
|
|
674
|
-
}
|
|
675
|
-
if (type === 'object') {
|
|
676
|
-
if (json.properties) {
|
|
677
|
-
const shape = {};
|
|
678
|
-
const required = json.required || [];
|
|
679
|
-
for (const [key, propSchema] of Object.entries(json.properties)) {
|
|
680
|
-
shape[key] = jsonSchemaToVLD(propSchema);
|
|
681
|
-
}
|
|
682
|
-
let obj = VldObject.create(shape);
|
|
683
|
-
if (!required.length) {
|
|
684
|
-
// If no required fields, make all optional
|
|
685
|
-
for (const key of Object.keys(shape)) {
|
|
686
|
-
if (!required.includes(key)) ;
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
if (json.additionalProperties === false) {
|
|
690
|
-
obj = obj.strict();
|
|
691
|
-
}
|
|
692
|
-
else if (json.additionalProperties === true) {
|
|
693
|
-
obj = obj.passthrough();
|
|
694
|
-
}
|
|
695
|
-
else if (json.additionalProperties) {
|
|
696
|
-
// additionalProperties is a schema
|
|
697
|
-
const valueSchema = jsonSchemaToVLD(json.additionalProperties);
|
|
698
|
-
obj = VldRecord.create(valueSchema);
|
|
699
|
-
}
|
|
700
|
-
return obj;
|
|
701
|
-
}
|
|
702
|
-
// Empty object schema
|
|
703
|
-
return VldObject.create({});
|
|
704
|
-
}
|
|
705
|
-
if (type === 'null') {
|
|
706
|
-
return VldNull.create();
|
|
707
|
-
}
|
|
708
|
-
if (Array.isArray(type)) {
|
|
709
|
-
// Union of types
|
|
710
|
-
const options = type.map((t) => {
|
|
711
|
-
return jsonSchemaToVLD({ ...json, type: t });
|
|
712
|
-
});
|
|
713
|
-
if (options.length > 0) {
|
|
714
|
-
return VldUnion.create(...options);
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
// Fallback to any
|
|
718
|
-
return VldAny.create();
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* VLD - Fast, Type-Safe Validation Library
|
|
723
|
-
* Zero dependencies, blazing fast performance
|
|
724
|
-
*
|
|
725
|
-
* This is the new modular implementation with:
|
|
726
|
-
* - Immutable validators (no memory leaks)
|
|
727
|
-
* - Secure deepMerge (no prototype pollution)
|
|
728
|
-
* - TypeScript strict mode support
|
|
729
|
-
* - Better performance through pooling and memoization
|
|
730
|
-
* - Plugin system for extensibility
|
|
731
|
-
* - Event system for validation lifecycle hooks
|
|
732
|
-
* - Result pattern for functional error handling
|
|
733
|
-
* - Colored console output for better debugging
|
|
734
|
-
* - Debug logging system
|
|
735
|
-
*/
|
|
736
|
-
// Import validators
|
|
737
|
-
/**
|
|
738
|
-
* Main API object with factory methods for all validators
|
|
739
|
-
*/
|
|
740
|
-
const v = {
|
|
741
|
-
// Primitive validators
|
|
742
|
-
string: () => VldString.create(),
|
|
743
|
-
number: () => VldNumber.create(),
|
|
744
|
-
int: () => VldNumber.create().int(),
|
|
745
|
-
int32: () => VldNumber.create().int().min(-2147483648).max(2147483647),
|
|
746
|
-
uint32: () => VldNumber.create().uint32(),
|
|
747
|
-
uint64: () => VldNumber.create().uint64(),
|
|
748
|
-
int64: () => VldNumber.create().int64(),
|
|
749
|
-
float32: () => VldNumber.create().float32(),
|
|
750
|
-
float64: () => VldNumber.create().float64(),
|
|
751
|
-
boolean: () => VldBoolean.create(),
|
|
752
|
-
date: () => VldDate.create(),
|
|
753
|
-
bigint: () => VldBigInt.create(),
|
|
754
|
-
symbol: () => VldSymbol.create(),
|
|
755
|
-
stringbool: (options) => VldStringBool.create(options),
|
|
756
|
-
// Complex validators
|
|
757
|
-
array: (item) => VldArray.create(item),
|
|
758
|
-
object: (shape) => VldObject.create(shape),
|
|
759
|
-
strictObject: (shape) => VldObject.create(shape).strict(),
|
|
760
|
-
looseObject: (shape) => VldObject.create(shape).passthrough(),
|
|
761
|
-
tuple: (...items) => VldTuple.create(...items),
|
|
762
|
-
record: (value) => VldRecord.create(value),
|
|
763
|
-
partialRecord: (value) => VldRecord.create(value).partial(),
|
|
764
|
-
looseRecord: (value) => VldRecord.create(value).loose(),
|
|
765
|
-
set: (item) => VldSet.create(item),
|
|
766
|
-
map: (key, value) => VldMap.create(key, value),
|
|
767
|
-
// Union and intersection
|
|
768
|
-
union: (...validators) => VldUnion.create(...validators),
|
|
769
|
-
intersection: (first, second) => VldIntersection.create(first, second),
|
|
770
|
-
discriminatedUnion: (discriminator, ...options) => VldDiscriminatedUnion.create(discriminator, [...options]),
|
|
771
|
-
xor: (...options) => VldXor.create([...options]),
|
|
772
|
-
// Literal and enum
|
|
773
|
-
literal: (value) => VldLiteral.create(value),
|
|
774
|
-
enum: (...values) => VldEnum.create(values),
|
|
775
|
-
// Special validators
|
|
776
|
-
any: () => VldAny.create(),
|
|
777
|
-
unknown: () => VldUnknown.create(),
|
|
778
|
-
void: () => VldVoid.create(),
|
|
779
|
-
never: () => VldNever.create(),
|
|
780
|
-
null: () => VldNull.create(),
|
|
781
|
-
undefined: () => VldUndefined.create(),
|
|
782
|
-
nan: () => VldNan.create(),
|
|
783
|
-
// NEVER constant - Zod 4 API parity for use in transforms
|
|
784
|
-
NEVER: VldNever.create(),
|
|
785
|
-
// Utility validators
|
|
786
|
-
optional: (validator) => VldOptional.create(validator),
|
|
787
|
-
nullable: (validator) => VldNullable.create(validator),
|
|
788
|
-
nullish: (validator) => VldNullish.create(validator),
|
|
789
|
-
exactOptional: (validator) => VldExactOptional.create(validator),
|
|
790
|
-
// Recursive schemas
|
|
791
|
-
lazy: (schemaGetter) => VldLazy.create(schemaGetter),
|
|
792
|
-
// JSON validator
|
|
793
|
-
json: (schema) => VldJson.create(schema),
|
|
794
|
-
// Custom validator for type-safe user-defined schemas
|
|
795
|
-
custom: (options) => custom(options),
|
|
796
|
-
// File validator for file uploads
|
|
797
|
-
file: () => file(),
|
|
798
|
-
// Function validator for function validation
|
|
799
|
-
function: () => functionValidator(),
|
|
800
|
-
// Preprocessing
|
|
801
|
-
preprocess: (preprocessor, schema) => VldPreprocess.create(preprocessor, schema),
|
|
802
|
-
// Coercion API
|
|
803
|
-
coerce: {
|
|
804
|
-
string: () => VldCoerceString.create(),
|
|
805
|
-
number: () => VldCoerceNumber.create(),
|
|
806
|
-
boolean: () => VldCoerceBoolean.create(),
|
|
807
|
-
date: () => VldCoerceDate.create(),
|
|
808
|
-
bigint: () => VldCoerceBigInt.create(),
|
|
809
|
-
},
|
|
810
|
-
// String format validators (Zod 4 parity)
|
|
811
|
-
email: (options) => email(options),
|
|
812
|
-
uuid: (options) => uuid(options),
|
|
813
|
-
uuidv4: () => uuidv4(),
|
|
814
|
-
hostname: () => hostname(),
|
|
815
|
-
emoji: () => emoji(),
|
|
816
|
-
base64: () => base64(),
|
|
817
|
-
base64url: () => base64url(),
|
|
818
|
-
hex: () => hex(),
|
|
819
|
-
jwt: () => jwt(),
|
|
820
|
-
nanoid: () => nanoid(),
|
|
821
|
-
cuid: () => cuid(),
|
|
822
|
-
cuid2: () => cuid2(),
|
|
823
|
-
ulid: () => ulid(),
|
|
824
|
-
ipv4: () => ipv4(),
|
|
825
|
-
ipv6: () => ipv6(),
|
|
826
|
-
mac: () => mac(),
|
|
827
|
-
cidrv4: () => cidrv4(),
|
|
828
|
-
cidrv6: () => cidrv6(),
|
|
829
|
-
e164: () => e164(),
|
|
830
|
-
hash: (algorithm) => hash(algorithm),
|
|
831
|
-
iso: {
|
|
832
|
-
date: () => iso.date(),
|
|
833
|
-
time: () => iso.time(),
|
|
834
|
-
dateTime: () => iso.dateTime(),
|
|
835
|
-
duration: () => iso.duration(),
|
|
836
|
-
},
|
|
837
|
-
stringFormat: (name, validator) => stringFormat(name, validator),
|
|
838
|
-
// Zod v4 parity string formats
|
|
839
|
-
xid: () => xid(),
|
|
840
|
-
guid: () => guid(),
|
|
841
|
-
httpUrl: () => httpUrl(),
|
|
842
|
-
// Template literal validator
|
|
843
|
-
templateLiteral: (...components) => templateLiteral(...components),
|
|
844
|
-
// Codec validators (binary data validators)
|
|
845
|
-
base64Bytes: () => VldBase64.create(),
|
|
846
|
-
hexBytes: () => VldHex.create(),
|
|
847
|
-
uint8Array: () => VldUint8Array.create(),
|
|
848
|
-
// Codec factory
|
|
849
|
-
codec: (inputValidator, outputValidator, transform) => VldCodec.create(inputValidator, outputValidator, transform),
|
|
850
|
-
// Promise validator (Zod v4 parity)
|
|
851
|
-
promise: (inner) => promise(inner)
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
export { VldIntersection, createLogger, createNoOpLogger, v as default, disableLogging, enableDebug, fromJSONSchema, getLogger, initLogger, setLogLevel, toJSONSchema, v };
|
|
855
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import{VLD_VALIDATOR_TYPES as V,configureSchemaCompositionFactories as S,VldPreprocess as O,VldBase as Z,VldExactOptional as E,VldNullish as M,VldNullable as L,VldOptional as I,resolveErrorMessage as _,VldPipe as T,VldDefault as N,VldPrefault as P,VldCatch as R,VldReadonly as U,VldMeta as D,VldRefine as $,VldTransform as F}from"./validators/base.js";export{VldBrand as ZodBranded}from"./validators/base.js";import{globalRegistry as J}from"./registry.js";export{registry}from"./registry.js";import{VldString as W}from"./validators/string.js";import{VldNumber as K}from"./validators/number.js";import{VldBoolean as G}from"./validators/boolean.js";import{VldDate as H}from"./validators/date.js";import{VldStringBool as X}from"./validators/string-bool.js";import{VldArray as Y}from"./validators/array.js";import{VldObject as Q}from"./validators/object.js";import{VldUnion as ee}from"./validators/union.js";import{VldLiteral as te}from"./validators/literal.js";import{VldBigInt as re}from"./validators/bigint.js";import{VldSymbol as ne}from"./validators/symbol.js";import{VldTuple as ae}from"./validators/tuple.js";import{VldRecord as oe}from"./validators/record.js";import{VldSet as ie}from"./validators/set.js";import{VldMap as se}from"./validators/map.js";import{VldEnum as ce}from"./validators/enum.js";import{VldIntersection as ue}from"./validators/intersection.js";import{VldAny as le}from"./validators/any.js";import{VldUnknown as me}from"./validators/unknown.js";import{VldVoid as de}from"./validators/void.js";import{VldNever as fe}from"./validators/never.js";import{VldNull as pe}from"./validators/null.js";import{VldUndefined as ye}from"./validators/undefined.js";import{VldNan as ve}from"./validators/nan.js";import{VldLazy as ge}from"./validators/lazy.js";import{VldDiscriminatedUnion as he}from"./validators/discriminated-union.js";import{VldXor as be}from"./validators/xor.js";import{VldJson as xe}from"./validators/json.js";import{templateLiteral as je}from"./validators/template-literal.js";export{VldTemplateLiteral as ZodTemplateLiteral}from"./validators/template-literal.js";import{custom as Ve}from"./validators/custom.js";export{VldCustom as ZodCustom,VldCustom as ZodSuccess}from"./validators/custom.js";import{VldFile as we,file as Se}from"./validators/file.js";import{functionValidator as Ae}from"./validators/function.js";export{VldFunction as ZodFunction}from"./validators/function.js";import{VldCodec as Oe}from"./validators/codec.js";import{VldBase64 as Ze}from"./validators/base64.js";import{VldHex as Ee}from"./validators/hex.js";import{VldUint8Array as Me}from"./validators/uint8array.js";import{promise as Le}from"./validators/promise.js";export{VldPromise as ZodPromise}from"./validators/promise.js";import{map as Ie}from"./compat/result.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"./compat/result.js";import{l as _e}from"./chunks/index-yjpbvFgw.js";export{s as setLocaleAsync}from"./chunks/index-yjpbvFgw.js";import{VldCoerceBigInt as Te,VldCoerceDate as Ne,VldCoerceBoolean as Pe,VldCoerceNumber as ke,VldCoerceString as Ce}from"./coercion/index.js";import{flattenError as Re,prettifyError as Ue,treeifyError as Be}from"./errors.js";export{prettifyErrorColored,prettifyErrorPlain}from"./errors.js";import{uuid as De,httpUrl as $e,email as ze,regexes as Fe,VldStringFormat as Je,ksuid as We,guid as qe,xid as Ke,stringFormat as Ge,iso as He,hash as Xe,e164 as Ye,creditCard as Qe,cidrv6 as et,cidrv4 as tt,mac as rt,ipv6 as nt,ipv4 as at,ulid as ot,cuid2 as it,cuid as st,nanoid as ct,jwt as ut,hex as lt,base64url as mt,base64 as dt,emoji as ft,hostname as pt,uuidv7 as yt,uuidv6 as vt,uuidv4 as gt,url as ht}from"./validators/string-formats.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"./chunks/index-CkbfQQ4n.js";export{createEmitter,createEventBus,withEmitter}from"./compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"./kernel.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"./pigment.js";import{V as bt}from"./chunks/errors-core-Cqi4-9ew.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"./locales/runtime.js";function xt(e,t={}){const r=function(e){const t=e.target;if("draft-4"===t)return{...e,target:"draft-04"};if("draft-7"===t)return{...e,target:"draft-07"};return e}(t),n=Vt(wt(e,r),r),a=r.target||"draft-2020-12";return"draft-04"===a?n.$schema??(n.$schema="http://json-schema.org/draft-04/schema#"):"draft-07"===a?n.$schema??(n.$schema="http://json-schema.org/draft-07/schema#"):"draft-2019-09"===a?n.$schema??(n.$schema="https://json-schema.org/draft/2019-09/schema"):"draft-2020-12"===a&&(n.$schema??(n.$schema="https://json-schema.org/draft/2020-12/schema")),n}function jt(e,t={}){if("boolean"==typeof e)return e?le.create():fe.create();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const n=Mt(r),a=n.meta();return t.registry&&a&&t.registry.add(n,a),n}function Vt(e,t){const r=t.target||"draft-2020-12",n={...e};if(Array.isArray(n.items)){const e=n.items.map(e=>Vt(e,t));"draft-2020-12"===r||"draft-2019-09"===r?(n.prefixItems=e,n.items=!1):n.items=e}else n.items&&"object"==typeof n.items&&(n.items=Vt(n.items,t));n.prefixItems&&(n.prefixItems=n.prefixItems.map(e=>Vt(e,t))),n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([e,r])=>[e,Vt(r,t)]))),n.additionalProperties&&"object"==typeof n.additionalProperties&&(n.additionalProperties=Vt(n.additionalProperties,t));for(const e of["anyOf","allOf","oneOf"])n[e]&&(n[e]=n[e].map(e=>Vt(e,t)));return n.not&&"object"==typeof n.not&&(n.not=Vt(n.not,t)),"openapi-3.0"===r&&function(e){if(Array.isArray(e.type)&&e.type.includes("null")){const t=e.type.filter(e=>"null"!==e);if(e.nullable=!0,1===t.length){const r=t[0];void 0!==r?e.type=r:delete e.type}else t.length>1?e.type=t:delete e.type}"number"==typeof e.exclusiveMinimum&&(e.minimum??(e.minimum=e.exclusiveMinimum),e.exclusiveMinimum=!0);"number"==typeof e.exclusiveMaximum&&(e.maximum??(e.maximum=e.exclusiveMaximum),e.exclusiveMaximum=!0)}(n),n}function wt(e,t){t.target;const r=e,n=e.validatorType;if("VldString"===e.constructor.name||n===V.STRING)return Ot(e,function(e,t){const r=t?.config?.jsonSchema||{},n={type:"string"};void 0!==r.exactLength?(n.minLength=r.exactLength,n.maxLength=r.exactLength):(void 0!==r.minLength&&(n.minLength=r.minLength),void 0!==r.maxLength&&(n.maxLength=r.maxLength));r.format&&(n.format=r.format);r.pattern&&(n.pattern=r.pattern);return n}(0,e),t);if("VldNumber"===e.constructor.name||n===V.NUMBER)return Ot(e,function(e){const t=e.config||{},r=t.jsonSchema||{},n=t.checks||[],a={type:r.type||"number"};void 0!==r.minimum&&(a.minimum=r.minimum);void 0!==r.maximum&&(a.maximum=r.maximum);void 0!==r.exclusiveMinimum&&(a.exclusiveMinimum=r.exclusiveMinimum);void 0!==r.exclusiveMaximum&&(a.exclusiveMaximum=r.exclusiveMaximum);void 0!==r.multipleOf&&(a.multipleOf=r.multipleOf);if(Object.keys(r).length>0)return a;for(const e of n){const t=e.toString();(t.includes(">=")||t.includes("min"))&&(a.minimum=0),(t.includes("<=")||t.includes("max"))&&(a.maximum=0),(t.includes("isInteger")||t.includes("int"))&&(a.type="integer"),t.includes("isSafeInteger")&&(a.type="integer"),t.includes("Number.isFinite")}return a}(e),t);if("VldBoolean"===e.constructor.name||n===V.BOOLEAN)return Ot(e,{type:"boolean"},t);if("VldBigInt"===e.constructor.name||n===V.BIGINT)return St(e,t,"BigInt",()=>function(e){const t=e.jsonSchema||e.config?.jsonSchema||{},r={type:"integer"};return Zt(r,"minimum","x-vld-minimum",t.minimum),Zt(r,"maximum","x-vld-maximum",t.maximum),Zt(r,"exclusiveMinimum","x-vld-exclusiveMinimum",t.exclusiveMinimum),Zt(r,"exclusiveMaximum","x-vld-exclusiveMaximum",t.exclusiveMaximum),r}(e));if("VldDate"===e.constructor.name||n===V.DATE)return St(e,t,"Date",()=>function(e){const t=e.jsonSchema||e.config?.jsonSchema||{},r={type:"string",format:"date-time"};t.formatMinimum&&(r.formatMinimum=t.formatMinimum);t.formatMaximum&&(r.formatMaximum=t.formatMaximum);t.formatExclusiveMinimum&&(r.formatExclusiveMinimum=t.formatExclusiveMinimum);t.formatExclusiveMaximum&&(r.formatExclusiveMaximum=t.formatExclusiveMaximum);return r}(e));if("VldArray"===e.constructor.name||n===V.ARRAY)return Ot(e,function(e,t){const r=e._item||e._inner||e.config?.itemValidator,n={type:"array"};r&&(n.items=wt(r,t));void 0!==e.config?.exactLength?(n.minItems=e.config.exactLength,n.maxItems=e.config.exactLength):(void 0!==e.config?.minLength&&(n.minItems=e.config.minLength),void 0!==e.config?.maxLength&&(n.maxItems=e.config.maxLength));e.config?.unique&&(n.uniqueItems=!0);return n}(e,t),t);if("VldObject"===e.constructor.name||n===V.OBJECT)return Ot(e,function(e,t){const r=e._shape||e.shape||e.config?.shape;if(!r)return{type:"object"};const n={},a=[];for(const[e,o]of Object.entries(r)){const r=o;n[e]=wt(r,t),Et(r)||a.push(e)}const o={type:"object",properties:n};a.length>0&&(o.required=a);e._passthrough||e._loose||e.config?.passthrough?o.additionalProperties=!0:e.config?.catchall?o.additionalProperties=wt(e.config.catchall,t):o.additionalProperties=!1;return o}(e,t),t);if("VldUnion"===e.constructor.name)return Ot(e,function(e,t){const r=e._validators||e._options||e.validators||[];return{anyOf:r.map(e=>wt(e,t))}}(e,t),t);if("VldLiteral"===e.constructor.name)return Ot(e,function(e){const t=e._literal??e.literal??e._value??e.value;return null===t?{type:"null"}:"string"==typeof t?{type:"string",const:t}:"number"==typeof t?{type:"number",const:t}:"boolean"==typeof t?{type:"boolean",const:t}:{const:t}}(e),t);if("VldEnum"===e.constructor.name)return Ot(e,function(e){const t=e._values||e.values;if(Array.isArray(t))return{enum:[...t]};return{}}(e),t);if("VldSet"===e.constructor.name||n===V.SET)return St(e,t,"Set",()=>function(e,t){const r=e.itemSchema||e.itemValidator||e._item||e._inner,n={type:"array",uniqueItems:!0,"x-vld-type":"set"};r&&(n.items=wt(r,t));return n}(e,t));if("VldMap"===e.constructor.name||n===V.MAP)return St(e,t,"Map",()=>function(e,t){const r=e.keySchema||e.keyValidator||e._key,n=e.valueSchema||e.valueValidator||e._value,a=r?wt(r,t):{},o=n?wt(n,t):{};return{type:"array","x-vld-type":"map",items:{type:"array",items:[a,o],minItems:2,maxItems:2}}}(e,t));if("VldRecord"===e.constructor.name||n===V.RECORD)return Ot(e,function(e,t){const r=e.valueSchema||e._value||e._inner||e.valueValidator;if(r)return{type:"object",additionalProperties:wt(r,t)};return{type:"object"}}(e,t),t);if("VldTuple"===e.constructor.name||n===V.TUPLE)return Ot(e,function(e,t){const r=e.items||e._items||e.validators;if(!r||!Array.isArray(r))return{type:"array"};return{type:"array",items:r.map(e=>wt(e,t)),minItems:r.length,maxItems:r.length}}(e,t),t);if("VldIntersection"===e.constructor.name)return Ot(e,function(e,t){const r=e._first||e.first,n=e._second||e.second,a=[];r&&a.push(wt(r,t));n&&a.push(wt(n,t));return 0===a.length?{}:1===a.length?a[0]??{}:{allOf:a}}(e,t),t);if("VldOptional"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{};const n=wt(r,t);return n}(e,t),t);if("VldNullable"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{type:"null"};const n=wt(r,t);if("string"==typeof n.type)return{type:[n.type,"null"]};if(Array.isArray(n.type))return n.type.push("null"),n;return{anyOf:[n,{type:"null"}]}}(e,t),t);if("VldNullish"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{};const n=wt(r,t);if("string"==typeof n.type)return{...n,type:[n.type,"null"]};return n}(e,t),t);if("VldExactOptional"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);return r?wt(r,t):{}}(e,t),t);if("VldLazy"===e.constructor.name)return Ot(e,{type:"object"},t);if("VldJson"===e.constructor.name)return Ot(e,{},t);if("VldAny"===e.constructor.name)return Ot(e,{},t);if("VldUnknown"===e.constructor.name)return Ot(e,{},t);if("VldNever"===e.constructor.name)return Ot(e,{not:{}},t);if("VldNull"===e.constructor.name)return Ot(e,{type:"null"},t);if("VldUndefined"===e.constructor.name)return St(e,t,"Undefined",()=>({not:{}}));if("VldNan"===e.constructor.name)return St(e,t,"NaN",()=>({type:"number",not:{}}));if("VldVoid"===e.constructor.name)return St(e,t,"Void",()=>({not:{}}));if("VldSymbol"===e.constructor.name)return St(e,t,"Symbol",()=>({}));if("VldBrand"===e.constructor.name)return Ot(e,wt(r.baseValidator,t),t);if("VldReadonly"===e.constructor.name)return Ot(e,wt(r.baseValidator,t),t);if("VldTransform"===e.constructor.name)return St(e,t,"Transform",()=>wt(At(r),t));if("VldMeta"===e.constructor.name){const n=wt(r.baseValidator,t);return Ot(e,n,t)}if("VldRefine"===e.constructor.name||"VldSuperRefine"===e.constructor.name)return Ot(e,wt(At(r),t),t);if("VldPipe"===e.constructor.name){const n="input"===t.io?r.first:r._next||r.second;return Ot(e,wt(n,t),t)}if("VldDefault"===e.constructor.name||"VldCatch"===e.constructor.name)return Ot(e,wt(At(r),t),t);if("VldPreprocess"===e.constructor.name)return St(e,t,"Preprocess",()=>wt(r._schema,t));if("VldCodec"===e.constructor.name){const n="input"===t.io?r.inputValidator:r.outputValidator;return Ot(e,wt(n,t),t)}if("VldCustom"===e.constructor.name)return St(e,t,"Custom",()=>({}));if("VldStringFormat"===e.constructor.name){return Ot(e,{type:"string",format:e._format},t)}return Ot(e,{},t)}function St(e,t,r,n){if("any"===t.unrepresentable)return Ot(e,{},t);if("vld"===t.unrepresentable)return Ot(e,n(),t);throw new Error(`${r} cannot be represented in JSON Schema`)}function At(e){return"function"==typeof e.unwrap?e.unwrap():e._inner||e._baseValidator||e.baseValidator||e.valueValidator}function Ot(e,t,r){if(!1===r.includeMetadata)return t;const n=function(e){const t=J.get(e),r=e,n="function"==typeof r.getMeta?r.getMeta():void 0;return t||n?{...n||{},...t||{}}:void 0}(e);if(!n)return t;const a={...t};return n.id&&(a.$id=n.id),n.title&&(a.title=n.title),n.description&&(a.description=n.description),n.examples&&!1!==r.includeExamples&&(a.examples=n.examples),void 0!==n.default&&(a.default=n.default),n.deprecated&&(a.deprecated=!0),n.readOnly&&(a.readOnly=!0),n.writeOnly&&(a.writeOnly=!0),a}function Zt(e,t,r,n){if(void 0===n)return;e[r]=n.toString();const a=function(e){const t=Number(e);if(Number.isSafeInteger(t))return BigInt(t)===e?t:void 0}(n);void 0!==a&&(e[t]=a)}function Et(e){const t=e.constructor.name;return"VldOptional"===t||"VldNullish"===t||"VldExactOptional"===t||e.validatorType===V.OPTIONAL||e.validatorType===V.NULLISH||e.validatorType===V.EXACT_OPTIONAL}function Mt(e){return function(e,t){const r={};t.$id&&(r.id=t.$id);t.title&&(r.title=t.title);t.description&&(r.description=t.description);t.examples&&(r.examples=t.examples);void 0!==t.default&&(r.default=t.default);t.deprecated&&(r.deprecated=!0);t.readOnly&&(r.readOnly=!0);t.writeOnly&&(r.writeOnly=!0);return Object.keys(r).length>0?e.meta(r):e}(function(e){if(e.$ref)return le.create();if(e.anyOf||e.oneOf){const t=(e.anyOf||e.oneOf).map(e=>Mt(e)).filter(Boolean);if(t.length>0)return ee.create(...t)}if(e.allOf){const t=e.allOf[0];if(void 0===t)return le.create();const r=Mt(t);if(e.allOf.length>1){const t=Mt({allOf:e.allOf.slice(1)});return ue.create(r,t)}return r}if(e.not)return le.create();if(void 0!==e.const)return te.create(e.const);if(e.enum)return ce.create(e.enum);const t=e.nullable&&"string"==typeof e.type?[e.type,"null"]:e.type;if("string"===t||void 0===t){let t=W.create();if(void 0!==e.minLength&&(t=t.min(e.minLength)),void 0!==e.maxLength&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),e.format)switch(e.format){case"date-time":case"date":case"time":break;case"email":return ze();case"uri":case"uri-reference":return $e();case"uuid":return De()}return t}if("number"===t||"integer"===t){let r=K.create();return"integer"===t&&(r=r.int()),void 0!==e.minimum&&(r=r.min(e.minimum)),void 0!==e.maximum&&(r=r.max(e.maximum)),"number"==typeof e.exclusiveMinimum&&(r=r.gt(e.exclusiveMinimum)),"number"==typeof e.exclusiveMaximum&&(r=r.lt(e.exclusiveMaximum)),!0===e.exclusiveMinimum&&void 0!==e.minimum&&(r=r.gt(e.minimum)),!0===e.exclusiveMaximum&&void 0!==e.maximum&&(r=r.lt(e.maximum)),void 0!==e.multipleOf&&(r=r.multipleOf(e.multipleOf)),r}if("boolean"===t)return G.create();if("array"===t){if(e.prefixItems&&e.prefixItems.length>0){const t=e.prefixItems.map(e=>Mt(e));return ae.create(...t)}if(Array.isArray(e.items)){const t=e.items.map(e=>Mt(e));return ae.create(...t)}return e.items&&!Array.isArray(e.items)?Y.create(Mt(e.items)):Y.create(le.create())}if("object"===t){if(e.properties){const t={},r=new Set(e.required||[]);for(const[n,a]of Object.entries(e.properties)){const e=Mt(a);t[n]=r.has(n)?e:e.optional()}let n=Q.create(t);if(!1===e.additionalProperties)n=n.strict();else if(!0===e.additionalProperties)n=n.passthrough();else if(e.additionalProperties){const t=Mt(e.additionalProperties);return oe.create(t)}return n}return Q.create({})}if("null"===t)return pe.create();if(Array.isArray(t)){const r=t.map(t=>Mt({...e,type:t,nullable:!1}));if(r.length>0)return ee.create(...r)}return le.create()}(e),e)}const Lt={debug:0,info:1,warn:2,error:3,silent:4},It="[0m",_t="[2m",Tt="[36m",Nt={debug:"[90m",info:"[34m",warn:"[33m",error:"[31m"},Pt={debug:"DEBUG",info:"INFO ",warn:"WARN ",error:"ERROR"};function kt(e={}){const t=e.name??"vld";let r=e.level??"warn";const n=e.handler??function(e){const t=e.colored??!0,r=e.timestamps??!0;return e=>{const n=[];if(r){const r=e.timestamp.toISOString().slice(11,23);n.push(t?`${_t}${r}${It}`:r)}const a=Pt[e.level],o=Nt[e.level];n.push(t?`${o}${a}${It}`:a),n.push(t?`${Tt}[${e.name}]${It}`:`[${e.name}]`),n.push(e.message);const i=n.join(" ");switch(e.level){case"debug":console.debug(i,void 0!==e.data?e.data:"");break;case"info":console.info(i,void 0!==e.data?e.data:"");break;case"warn":console.warn(i,void 0!==e.data?e.data:"");break;case"error":console.error(i,void 0!==e.data?e.data:"")}}}(e),a=(e,a,o)=>{if(Lt[e]<Lt[r])return;const i={level:e,message:a,data:o,timestamp:new Date,name:t};n(i)};return{debug:(e,t)=>a("debug",e,t),info:(e,t)=>a("info",e,t),warn:(e,t)=>a("warn",e,t),error:(e,t)=>a("error",e,t),isLevelEnabled:e=>Lt[e]>=Lt[r],setLevel:e=>{r=e},getLevel:()=>r,child:r=>kt({...e,name:`${t}:${r}`})}}let Ct=null;function Rt(e){return Ct=kt({name:"vld",...e}),Ct}function Ut(){return Ct}function Bt(e){Ct&&Ct.setLevel(e)}function Dt(){Ct?Ct.setLevel("debug"):Rt({level:"debug"})}function $t(){Ct&&Ct.setLevel("silent")}function zt(){return kt({level:"silent"})}const Ft=Symbol.for("@oxog/vld/global-state"),Jt=globalThis,Wt=Jt[Ft]??(Jt[Ft]={config:{}});function qt(e){return void 0===e||(Wt.config={...Wt.config,...e},"customError"in e?Wt.errorMap=e.customError:"errorMap"in e&&(Wt.errorMap=e.errorMap)),{...Wt.config}}function Kt(e){Wt.errorMap=e,Wt.config={...Wt.config,errorMap:e}}function Gt(){return Wt.errorMap}function Ht(e){const t=Object.keys(e).filter(e=>!/^\d+$/.test(e)).map(t=>e[t]).filter(e=>"string"==typeof e||"number"==typeof e),r=Array.from(new Set(t));if(0===r.length)throw new Error("nativeEnum requires at least one string or number value");return r}function Xt(e,t,r){let n=e;for(const e of t){const t=String(e),r=n[t];r&&!Array.isArray(r)||(n[t]={_errors:[]}),n=n[t]}n._errors.push(r)}function Yt(e){return void 0===e?void 0:_(e,"Refinement check failed")}function Qt(e){return Ve({parse:t=>{const r=e(t,{addIssue:()=>{},path:[]});if(null!==r&&"object"==typeof r&&"function"==typeof r.then)throw new Error("Use parseAsync for async transforms");return r},parseAsync:async t=>await Promise.resolve(e(t,{addIssue:()=>{},path:[]}))})}function er(e,t){return Ve({parse:r=>{const n=e(r);if(null!==n&&"object"==typeof n&&"function"==typeof n.then)throw new Error("Use parseAsync for async refinements");if(!n)throw new Error(Yt(t)||"Refinement check failed");return r},parseAsync:async r=>{if(!await e(r))throw new Error(Yt(t)||"Refinement check failed");return r}})}const tr={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6},rr={},nr=Symbol.for("vld_brand"),ar=Symbol.for("VldInput"),or=Symbol.for("VldOutput"),ir={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"},sr={getParsedType:function(e){return null===e?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e},propertyKeyTypes:new Set(["string","number","symbol"]),primitiveTypes:new Set(["string","number","bigint","boolean","symbol","undefined","null"]),assert:(e,t="Assertion failed")=>{if(!e)throw new Error(t)},assertNever:e=>{throw new Error(`Unexpected value: ${String(e)}`)},joinValues:(e,t=" | ")=>e.map(e=>JSON.stringify(e)).join(t),jsonStringifyReplacer:(e,t)=>"bigint"==typeof t?t.toString():t,nullish:e=>null==e,cached:e=>{let t,r=!1;return()=>(r||(t=e(),r=!0),t)}},cr={util:sr,regexes:Fe,locales:_e,NEVER:fe.create(),TimePrecision:tr,ZodIssueCode:ir,globalRegistry:J,config:qt,getErrorMap:Gt,setErrorMap:Kt,parse:(e,t)=>e.parse(t),safeParse:(e,t)=>e.safeParse(t),parseAsync:(e,t)=>e.parseAsync(t),safeParseAsync:(e,t)=>e.safeParseAsync(t)};function ur(e){return Q.create(e||{})}function lr(e,t,r){const n=r.get(e);if(n)return n;if(e instanceof ge){const n=e,a=ge.create(()=>lr(n.unwrap(),t,r));return r.set(e,a),a}const a=function(e,t){const r=e;if(e instanceof Q){const n=e.shape,a={};let o=!1;for(const e of Object.keys(n))a[e]=t(n[e]),o||(o=a[e]!==n[e]);let i=r.config.catchall;if(i){const e=t(i);o||(o=e!==i),i=e}return o?new Q({...r.config,shape:a,catchall:i}):e}if(e instanceof Y){const n=t(r.element);return n===r.element?e:Y.create(n)}if(e instanceof ie){const n=t(r.itemSchema);return n===r.itemSchema?e:ie.create(n)}if(e instanceof se){const n=t(r.keySchema),a=t(r.valueSchema);return n===r.keySchema&&a===r.valueSchema?e:se.create(n,a)}if(e instanceof oe){const n=t(r.valueSchema),a=r.keySchema?t(r.keySchema):void 0,o=void 0!==r.keySchema&&a!==r.keySchema;return n!==r.valueSchema||o?oe.create(n,a):e}if(e instanceof ae){const n=e.items.map(t),a=n.some((e,t)=>e!==r.items[t]),o=null==r.restValidator?void 0:t(r.restValidator),i=null!=r.restValidator&&o!==r.restValidator;return a||i?new ae(n,r.errorMessage,o):e}if(e instanceof ee){const n=r.validators.map(t);return n.some((e,t)=>e!==r.validators[t])?new ee(n,r.errorMessage):e}if(e instanceof be){const n=r._options.map(t);return n.some((e,t)=>e!==r._options[t])?new be(n):e}if(e instanceof he){const n=r._options.map(t);return n.some((e,t)=>e!==r._options[t])?ee.create(...n):e}if(e instanceof ue){const n=t(r.validatorA),a=t(r.validatorB);return n===r.validatorA&&a===r.validatorB?e:ue.create(n,a)}if(e instanceof T){const n=t(r.first),a=t(r.second);return n===r.first&&a===r.second?e:new T(n,a)}if(e instanceof I){const n=t(r.baseValidator);return n===r.baseValidator?e:I.create(n)}if(e instanceof L){const n=t(r.baseValidator);return n===r.baseValidator?e:L.create(n)}if(e instanceof M){const n=t(r.baseValidator);return n===r.baseValidator?e:M.create(n)}if(e instanceof E){const n=t(r.baseValidator);return n===r.baseValidator?e:E.create(n)}if(e instanceof N){const n=t(r.baseValidator);return n===r.baseValidator?e:new N(n,r.defaultValue)}if(e instanceof P){const n=t(r.baseValidator);return n===r.baseValidator?e:new P(n,r.defaultValue)}if(e instanceof R){const n=t(r.baseValidator);return n===r.baseValidator?e:new R(n,r.fallbackValue)}if(e instanceof U){const n=t(r.baseValidator);return n===r.baseValidator?e:new U(n)}if(e instanceof D){const n=t(r.baseValidator);return n===r.baseValidator?e:new D(n,r.metadata)}if(e instanceof $){const n=t(r.baseValidator);return n===r.baseValidator?e:new $(n,r.predicate,r.customMessage)}if(e instanceof F){const n=t(r.baseValidator);return n===r.baseValidator?e:new F(n,r.transformer)}if(e instanceof O){const n=t(r._schema);return n===r._schema?e:new O(r._preprocessor,n)}return e}(e,e=>lr(e,t,r)),o=t(a)??a;return r.set(e,o),o}function mr(e){return lr(e,e=>e instanceof Q?e.partial():void 0,new Map)}function dr(e){return lr(e,e=>e instanceof T?e.first:void 0,new Map)}function fr(e){return lr(e,e=>e instanceof T?e.second:void 0,new Map)}S({array:e=>Y.create(e),union:(e,t)=>ee.create(e,t),intersection:(e,t)=>ue.create(e,t),toJSONSchema:(e,t)=>xt(e,t)});const pr={string:()=>W.create(),number:()=>K.create(),int:()=>K.create().int(),int32:()=>K.create().int().min(-2147483648).max(2147483647),uint32:()=>K.create().uint32(),uint64:()=>K.create().uint64(),int64:()=>K.create().int64(),float32:()=>K.create().float32(),float64:()=>K.create().float64(),boolean:()=>G.create(),date:()=>H.create(),bigint:()=>re.create(),symbol:()=>ne.create(),stringbool:e=>X.create(e),array:e=>Y.create(e),object:ur,strictObject:function(e){return ur(e).strict()},looseObject:function(e){return ur(e).passthrough()},tuple:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z),r=ae.create(...t);return Array.isArray(e[0])&&e[1]instanceof Z?r.rest(e[1]):r},record:function(e,t){return void 0===t?oe.create(e):oe.create(t,e)},partialRecord:function(e,t){return void 0===t?oe.create(e).partial():oe.create(t,e).partial()},looseRecord:function(e,t){return void 0===t?oe.create(e).loose():oe.create(t,e).loose()},set:e=>ie.create(e),map:(e,t)=>se.create(e,t),union:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z);return ee.create(...t)},intersection:(e,t)=>ue.create(e,t),discriminatedUnion:function(e,...t){const r=Array.isArray(t[0])?t[0]:t.filter(e=>e instanceof Z);return he.create(e,r)},xor:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z);return be.create(t)},keyof:e=>e.keyof(),deepPartial:mr,input:dr,output:fr,literal:function(e){return te.create(e)},enum:function(...e){const t=e[0],r=Array.isArray(t)?t:null!==t&&"object"==typeof t?Ht(t):e.filter(e=>"string"==typeof e||"number"==typeof e);return ce.create(r)},nativeEnum:e=>ce.create(Ht(e)),any:()=>le.create(),unknown:()=>me.create(),void:()=>de.create(),never:()=>fe.create(),null:()=>pe.create(),undefined:()=>ye.create(),nan:()=>ve.create(),NEVER:fe.create(),TimePrecision:tr,ZodIssueCode:ir,ZodFirstPartyTypeKind:rr,optional:e=>I.create(e),nullable:e=>L.create(e),nullish:e=>M.create(e),exactOptional:e=>E.create(e),nonoptional:(e,t)=>e.refine(e=>void 0!==e,Yt(t)),catch:(e,t)=>e.catch(t),prefault:(e,t)=>e.prefault(t),readonly:e=>e.readonly(),pipe:(e,t)=>e.pipe(t),clone:e=>e,describe:(e,t)=>e instanceof Z?e.describe(t||""):me.create().describe(e),meta:(e,t)=>e instanceof Z?e.meta(t||{}):me.create().meta(e),transform:(e,t)=>e instanceof Z?e.transform(t||(e=>e)):Qt(e),overwrite:e=>Qt(e),refine:(e,t,r)=>e instanceof Z?e.refine(t,Yt(r)):er(e,t),check:(e,t,r)=>e instanceof Z?e.check(t,Yt(r)):er(e,t),superRefine:(e,t)=>e instanceof Z?e.superRefine(t||(()=>{})):function(e){return me.create().superRefine(e)}(e),property:function(e,t,r){return Ve({parse:n=>{if("object"!=typeof n||null===n||!(e in n))throw new Error(Yt(r)||`Expected object with property "${e}"`);const a=t.safeParse(n[e]);if(!a.success)throw new Error(Yt(r)||a.error.message);return n}})},instanceof:(e,t)=>Ve({parse:r=>{if(!(r instanceof e))throw new Error(Yt(t)||`Expected instance of ${e.name||"provided constructor"}`);return r}}),config:qt,setErrorMap:Kt,getErrorMap:Gt,core:cr,util:sr,locales:_e,lazy:e=>ge.create(e),json:e=>xe.create(e),custom:e=>Ve(e),file:()=>Se(),function:()=>Ae(),preprocess:(e,t)=>O.create(e,t),coerce:{string:()=>Ce.create(),number:()=>ke.create(),boolean:()=>Pe.create(),date:()=>Ne.create(),bigint:()=>Te.create()},email:e=>ze(e),url:e=>ht(e),uuid:e=>De(e),uuidv4:()=>gt(),uuidv6:()=>vt(),uuidv7:()=>yt(),hostname:()=>pt(),emoji:()=>ft(),base64:()=>dt(),base64url:()=>mt(),hex:()=>lt(),jwt:()=>ut(),nanoid:()=>ct(),cuid:()=>st(),cuid2:()=>it(),ulid:()=>ot(),ipv4:()=>at(),ipv6:()=>nt(),mac:()=>rt(),cidrv4:()=>tt(),cidrv6:()=>et(),creditCard:e=>Qe(e),e164:()=>Ye(),hash:e=>Xe(e),iso:{ZodISODate:Je,ZodISODateTime:Je,ZodISODuration:Je,ZodISOTime:Je,date:()=>He.date(),time:e=>He.time(e),datetime:e=>He.datetime(e),dateTime:e=>He.dateTime(e),duration:()=>He.duration()},stringFormat:(e,t)=>Ge(e,t),minLength:(e,t)=>W.create().min(e,t),maxLength:(e,t)=>W.create().max(e,t),length:(e,t)=>W.create().length(e,t),regex:(e,t)=>W.create().regex(e,t),startsWith:(e,t)=>W.create().startsWith(e,t),endsWith:(e,t)=>W.create().endsWith(e,t),includes:(e,t)=>W.create().includes(e,t),trim:()=>W.create().trim(),toLowerCase:()=>W.create().toLowerCase(),lowercase:()=>W.create().toLowerCase(),toUpperCase:()=>W.create().toUpperCase(),uppercase:()=>W.create().toUpperCase(),gt:(e,t)=>K.create().gt(e,t),gte:(e,t)=>K.create().gte(e,t),lt:(e,t)=>K.create().lt(e,t),lte:(e,t)=>K.create().lte(e,t),positive:e=>K.create().positive(e),negative:e=>K.create().negative(e),nonnegative:e=>K.create().nonnegative(e),nonpositive:e=>K.create().nonpositive(e),multipleOf:(e,t)=>K.create().multipleOf(e,t),minSize:(e,t)=>W.create().min(e,t),maxSize:(e,t)=>W.create().max(e,t),size:(e,t)=>W.create().length(e,t),normalize:e=>W.create().transform(t=>t.normalize(e)),slugify:()=>W.create().transform(e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")),mime:(e,t)=>we.create().mime(e,t),xid:()=>Ke(),guid:()=>qe(),httpUrl:()=>$e(),ksuid:()=>We(),regexes:Fe,templateLiteral:(...e)=>je(...e),base64Bytes:()=>Ze.create(),hexBytes:()=>Ee.create(),uint8Array:()=>Me.create(),codec:(e,t,r)=>Oe.create(e,t,r),invertCodec:e=>e.invert(),promise:e=>Le(e),parse:(e,t)=>e.parse(t),safeParse:(e,t)=>e.safeParse(t),parseAsync:(e,t)=>e.parseAsync(t),safeParseAsync:(e,t)=>e.safeParseAsync(t),decode:(e,t)=>e.parse(t),safeDecode:(e,t)=>e.safeParse(t),decodeAsync:(e,t)=>e.parseAsync(t),safeDecodeAsync:(e,t)=>e.safeParseAsync(t),encode:(e,t)=>e.encode(t),safeEncode:(e,t)=>e.safeEncode(t),encodeAsync:(e,t)=>e.encodeAsync(t),safeEncodeAsync:(e,t)=>e.safeEncodeAsync(t),formatError:e=>{const t={_errors:[]};if(e instanceof bt){for(const r of e.issues)Xt(t,r.path,r.message);return t}return t._errors.push(function(e){return e instanceof Error?e.message:String(e)}(e)),t},treeifyError:Be,prettifyError:Ue,flattenError:Re,toJSONSchema:xt,fromJSONSchema:jt},yr=pr,{string:vr,number:gr,int:hr,int32:br,uint32:xr,uint64:jr,int64:Vr,float32:wr,float64:Sr,boolean:Ar,date:Or,bigint:Zr,symbol:Er,stringbool:Mr,array:Lr,object:Ir,strictObject:_r,looseObject:Tr,tuple:Nr,record:Pr,partialRecord:kr,looseRecord:Cr,set:Rr,union:Ur,intersection:Br,discriminatedUnion:Dr,xor:$r,keyof:zr,literal:Fr,nativeEnum:Jr,any:Wr,unknown:qr,nan:Kr,optional:Gr,nullable:Hr,nullish:Xr,exactOptional:Yr,nonoptional:Qr,readonly:en,pipe:tn,clone:rn,describe:nn,meta:an,transform:on,overwrite:sn,refine:cn,check:un,superRefine:ln,property:mn,config:dn,setErrorMap:fn,getErrorMap:pn,locales:yn,lazy:vn,json:gn,custom:hn,file:bn,preprocess:xn,coerce:jn,email:Vn,url:wn,uuid:Sn,uuidv4:An,uuidv6:On,uuidv7:Zn,hostname:En,emoji:Mn,base64:Ln,base64url:In,hex:_n,jwt:Tn,nanoid:Nn,cuid:Pn,cuid2:kn,ulid:Cn,ipv4:Rn,ipv6:Un,mac:Bn,cidrv4:Dn,cidrv6:$n,creditCard:zn,e164:Fn,hash:Jn,iso:Wn,stringFormat:qn,normalize:Kn,slugify:Gn,mime:Hn,xid:Xn,guid:Yn,httpUrl:Qn,ksuid:ea,regexes:ta,templateLiteral:ra,base64Bytes:na,hexBytes:aa,uint8Array:oa,codec:ia,promise:sa,prefault:ca,parse:ua,safeParse:la,parseAsync:ma,safeParseAsync:da,decode:fa,safeDecode:pa,decodeAsync:ya,safeDecodeAsync:va,encode:ga,safeEncode:ha,encodeAsync:ba,safeEncodeAsync:xa,formatError:ja,NEVER:Va}=pr,wa=pr.catch,Sa=pr.enum,Aa=pr.function,Oa=pr.instanceof,Za=pr.map,Ea=pr.never,Ma=pr.null,La=pr.undefined,Ia=pr.void,_a=pr,Ta=W;function Na(e,t){return e instanceof Z&&t instanceof Z?pr.map(e,t):Ie(e,t)}const Pa=(e,t)=>pr.string().min(e,t),ka=(e,t)=>pr.string().max(e,t),Ca=(e,t)=>pr.string().length(e,t),Ra=(e,t)=>pr.string().regex(e,t),Ua=(e,t)=>pr.string().startsWith(e,t),Ba=(e,t)=>pr.string().endsWith(e,t),Da=(e,t)=>pr.string().includes(e,t),$a=()=>pr.string().trim(),za=()=>pr.string().toLowerCase(),Fa=za,Ja=()=>pr.string().toUpperCase(),Wa=Ja,qa=(e,t)=>pr.number().gt(e,t),Ka=(e,t)=>pr.number().gte(e,t),Ga=(e,t)=>pr.number().lt(e,t),Ha=(e,t)=>pr.number().lte(e,t),Xa=e=>pr.number().positive(e),Ya=e=>pr.number().negative(e),Qa=e=>pr.number().nonnegative(e),eo=e=>pr.number().nonpositive(e),to=(e,t)=>pr.number().multipleOf(e,t),ro=Pa,no=ka,ao=Ca;export{nr as $brand,ar as $input,or as $output,Va as NEVER,tr as TimePrecision,Z as VldBase,bt as VldError,ue as VldIntersection,D as VldMeta,le as ZodAny,Y as ZodArray,Je as ZodBase64,Je as ZodBase64URL,re as ZodBigInt,re as ZodBigIntFormat,G as ZodBoolean,Je as ZodCIDRv4,Je as ZodCIDRv6,Je as ZodCUID,Je as ZodCUID2,R as ZodCatch,Oe as ZodCodec,Je as ZodCreditCard,Je as ZodCustomStringFormat,H as ZodDate,N as ZodDefault,he as ZodDiscriminatedUnion,Je as ZodE164,Je as ZodEmail,Je as ZodEmoji,ce as ZodEnum,bt as ZodError,E as ZodExactOptional,we as ZodFile,rr as ZodFirstPartyTypeKind,Je as ZodGUID,Je as ZodIPv4,Je as ZodIPv6,Je as ZodISODate,Je as ZodISODateTime,Je as ZodISODuration,Je as ZodISOTime,ue as ZodIntersection,ir as ZodIssueCode,xe as ZodJSON,Je as ZodJWT,Je as ZodKSUID,ge as ZodLazy,te as ZodLiteral,Je as ZodMAC,se as ZodMap,D as ZodMeta,ve as ZodNaN,Je as ZodNanoID,fe as ZodNever,$ as ZodNonOptional,pe as ZodNull,L as ZodNullable,K as ZodNumber,K as ZodNumberFormat,Q as ZodObject,I as ZodOptional,T as ZodPipe,P as ZodPrefault,O as ZodPreprocess,U as ZodReadonly,bt as ZodRealError,oe as ZodRecord,ie as ZodSet,W as ZodString,Je as ZodStringFormat,ne as ZodSymbol,F as ZodTransform,ae as ZodTuple,Z as ZodType,Je as ZodULID,Je as ZodURL,Je as ZodUUID,ye as ZodUndefined,ee as ZodUnion,me as ZodUnknown,de as ZodVoid,Je as ZodXID,be as ZodXor,Ta as _ZodString,_a as _default,Aa as _function,Wr as any,Lr as array,Ln as base64,na as base64Bytes,In as base64url,Zr as bigint,Ar as boolean,wa as catch,un as check,Dn as cidrv4,$n as cidrv6,rn as clone,ia as codec,jn as coerce,dn as config,cr as core,kt as createLogger,zt as createNoOpLogger,zn as creditCard,Pn as cuid,kn as cuid2,hn as custom,Or as date,fa as decode,ya as decodeAsync,mr as deepPartial,pr as default,nn as describe,$t as disableLogging,Dr as discriminatedUnion,Fn as e164,Vn as email,Mn as emoji,Dt as enableDebug,ga as encode,ba as encodeAsync,Ba as endsWith,Sa as enum,Yr as exactOptional,bn as file,Re as flattenError,wr as float32,Sr as float64,ja as formatError,jt as fromJSONSchema,Aa as function,pn as getErrorMap,Ut as getLogger,J as globalRegistry,qa as gt,Ka as gte,Yn as guid,Jn as hash,_n as hex,aa as hexBytes,En as hostname,Qn as httpUrl,Da as includes,Rt as initLogger,dr as input,Oa as instanceof,hr as int,br as int32,Vr as int64,Br as intersection,Rn as ipv4,Un as ipv6,Wn as iso,gn as json,Tn as jwt,zr as keyof,ea as ksuid,vn as lazy,Ca as length,Fr as literal,yn as locales,Tr as looseObject,Cr as looseRecord,Fa as lowercase,Ga as lt,Ha as lte,Bn as mac,Na as map,Za as mapSchema,ka as maxLength,no as maxSize,an as meta,Hn as mime,Pa as minLength,ro as minSize,to as multipleOf,Kr as nan,Nn as nanoid,Jr as nativeEnum,Ya as negative,Ea as never,Qa as nonnegative,Qr as nonoptional,eo as nonpositive,Kn as normalize,Ma as null,Hr as nullable,Xr as nullish,gr as number,Ir as object,Gr as optional,fr as output,sn as overwrite,ua as parse,ma as parseAsync,kr as partialRecord,tn as pipe,Xa as positive,ca as prefault,xn as preprocess,Ue as prettifyError,sa as promise,mn as property,en as readonly,Pr as record,cn as refine,Ra as regex,ta as regexes,pa as safeDecode,va as safeDecodeAsync,ha as safeEncode,xa as safeEncodeAsync,la as safeParse,da as safeParseAsync,Rr as set,fn as setErrorMap,Bt as setLogLevel,ao as size,Gn as slugify,Ua as startsWith,_r as strictObject,vr as string,qn as stringFormat,Mr as stringbool,ln as superRefine,Er as symbol,ra as templateLiteral,xt as toJSONSchema,za as toLowerCase,Ja as toUpperCase,on as transform,Be as treeifyError,$a as trim,Nr as tuple,xr as uint32,jr as uint64,oa as uint8Array,Cn as ulid,La as undefined,Ur as union,qr as unknown,Wa as uppercase,wn as url,sr as util,Sn as uuid,An as uuidv4,On as uuidv6,Zn as uuidv7,pr as v,Ia as void,Xn as xid,$r as xor,yr as z};
|