@oxog/vld 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -1
- package/LICENSE +20 -20
- package/README.md +101 -37
- package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
- package/dist/chunks/{index-CETyGkrv.js → index-0R2ntSud.js} +16 -402
- package/dist/chunks/index-BvH403Yy.js +88 -0
- package/dist/chunks/security-B0Pd_vSY.js +35 -0
- package/dist/chunks/string-BJRQod3t.js +530 -0
- package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +83 -0
- package/dist/cjs/chunks/index-BkI37108.cjs +538 -0
- package/dist/cjs/chunks/index-Cc3bjUMX.cjs +91 -0
- package/dist/cjs/chunks/security-Dc3Jh13T.cjs +37 -0
- package/dist/cjs/chunks/string-BKZrc4hs.cjs +533 -0
- package/dist/cjs/cli/bin.cjs +506 -0
- package/dist/cjs/cli/index.cjs +209 -0
- package/dist/cjs/codecs/index.cjs +45 -0
- package/dist/{chunks/date-ODue_rtq.js → cjs/coercion/index.cjs} +185 -103
- package/dist/cjs/compat/emitter.cjs +184 -0
- package/dist/cjs/compat/result.cjs +189 -0
- package/dist/cjs/errors.cjs +6 -213
- package/dist/cjs/index.cjs +1558 -9647
- package/dist/cjs/kernel.cjs +415 -0
- package/dist/cjs/locales/af.cjs +108 -0
- package/dist/cjs/locales/ar.cjs +108 -0
- package/dist/cjs/locales/bn.cjs +108 -0
- package/dist/cjs/locales/da.cjs +108 -0
- package/dist/cjs/locales/de.cjs +108 -0
- package/dist/cjs/locales/en.cjs +108 -0
- package/dist/cjs/locales/es-MX.cjs +107 -0
- package/dist/cjs/locales/es.cjs +96 -0
- package/dist/cjs/locales/fi.cjs +108 -0
- package/dist/cjs/locales/fr.cjs +96 -0
- package/dist/cjs/locales/hi.cjs +108 -0
- package/dist/cjs/locales/id.cjs +108 -0
- package/dist/cjs/locales/index.cjs +41 -2875
- package/dist/cjs/locales/it.cjs +108 -0
- package/dist/cjs/locales/ja.cjs +108 -0
- package/dist/cjs/locales/ko.cjs +108 -0
- package/dist/cjs/locales/lazy.cjs +42 -3023
- package/dist/cjs/locales/nl.cjs +108 -0
- package/dist/cjs/locales/no.cjs +108 -0
- package/dist/cjs/locales/pl.cjs +108 -0
- package/dist/cjs/locales/pt-BR.cjs +108 -0
- package/dist/cjs/locales/pt.cjs +108 -0
- package/dist/cjs/locales/ru.cjs +108 -0
- package/dist/cjs/locales/runtime.cjs +51 -0
- package/dist/cjs/locales/sv.cjs +108 -0
- package/dist/cjs/locales/sw.cjs +108 -0
- package/dist/cjs/locales/th.cjs +108 -0
- package/dist/cjs/locales/tr.cjs +108 -0
- package/dist/cjs/locales/vi.cjs +108 -0
- package/dist/cjs/locales/zh.cjs +108 -0
- package/dist/cjs/mini.cjs +121 -7208
- package/dist/cjs/pigment.cjs +207 -0
- package/dist/cjs/plugins/index.cjs +12 -0
- package/dist/cjs/registry.cjs +37 -0
- package/dist/cjs/v3/index.cjs +425 -0
- package/dist/cjs/v4/core/index.cjs +894 -0
- package/dist/cjs/v4/index.cjs +425 -0
- package/dist/cjs/v4/locales/index.cjs +130 -0
- package/dist/cjs/v4/mini/index.cjs +509 -0
- package/dist/cjs/v4-mini/index.cjs +532 -0
- package/dist/cjs/validators/any.cjs +40 -0
- package/dist/cjs/validators/array.cjs +283 -0
- package/dist/cjs/validators/base.cjs +887 -0
- package/dist/cjs/validators/base64.cjs +73 -0
- package/dist/cjs/validators/bigint.cjs +232 -0
- package/dist/cjs/validators/boolean.cjs +146 -0
- package/dist/cjs/validators/codec.cjs +205 -0
- package/dist/cjs/validators/custom.cjs +71 -0
- package/dist/cjs/validators/date.cjs +278 -0
- package/dist/cjs/validators/discriminated-union.cjs +130 -0
- package/dist/cjs/validators/enum.cjs +154 -0
- package/dist/cjs/validators/file.cjs +130 -0
- package/dist/cjs/validators/function.cjs +63 -0
- package/dist/cjs/validators/hex.cjs +70 -0
- package/dist/cjs/validators/index.cjs +123 -0
- package/dist/cjs/validators/intersection.cjs +120 -0
- package/dist/cjs/validators/json.cjs +70 -0
- package/dist/cjs/validators/lazy.cjs +53 -0
- package/dist/cjs/validators/literal.cjs +64 -0
- package/dist/cjs/validators/map.cjs +218 -0
- package/dist/cjs/validators/nan.cjs +41 -0
- package/dist/cjs/validators/never.cjs +36 -0
- package/dist/cjs/validators/null.cjs +43 -0
- package/dist/cjs/validators/number.cjs +427 -0
- package/dist/cjs/validators/object.cjs +868 -0
- package/dist/cjs/validators/promise.cjs +115 -0
- package/dist/cjs/validators/record.cjs +262 -0
- package/dist/cjs/validators/set.cjs +203 -0
- package/dist/cjs/validators/string-bool.cjs +124 -0
- package/dist/cjs/validators/string-formats.cjs +168 -0
- package/dist/cjs/validators/string.cjs +12 -0
- package/dist/cjs/validators/symbol.cjs +62 -0
- package/dist/cjs/validators/template-literal.cjs +108 -0
- package/dist/cjs/validators/tuple.cjs +187 -0
- package/dist/cjs/validators/uint8array.cjs +106 -0
- package/dist/cjs/validators/undefined.cjs +43 -0
- package/dist/cjs/validators/union.cjs +191 -0
- package/dist/cjs/validators/unknown.cjs +40 -0
- package/dist/cjs/validators/void.cjs +48 -0
- package/dist/cjs/validators/xor.cjs +69 -0
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +407 -0
- package/dist/cli/commands/benchmark.d.ts +1 -2
- package/dist/cli/commands/validate.d.ts +1 -2
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +205 -0
- package/dist/codecs/index.d.ts +21 -4
- package/dist/codecs/index.js +11 -4
- package/dist/coercion/bigint.d.ts +2 -3
- package/dist/coercion/boolean.d.ts +3 -3
- package/dist/coercion/date.d.ts +3 -3
- package/dist/coercion/index.d.ts +5 -6
- package/dist/coercion/index.js +473 -5
- package/dist/coercion/number.d.ts +2 -3
- package/dist/coercion/string.d.ts +2 -3
- package/dist/compat/emitter.d.ts +0 -1
- package/dist/compat/emitter.js +0 -1
- package/dist/compat/index.d.ts +4 -5
- package/dist/compat/result.d.ts +1 -2
- package/dist/compat/result.js +0 -1
- package/dist/errors-core.d.ts +39 -0
- package/dist/errors.d.ts +4 -54
- package/dist/errors.js +4 -68
- package/dist/events.d.ts +3 -4
- package/dist/index.d.ts +1195 -600
- package/dist/index.js +1262 -44
- package/dist/kernel.d.ts +2 -3
- package/dist/kernel.js +10 -6
- package/dist/locales/af.d.ts +1 -2
- package/dist/locales/af.js +0 -1
- package/dist/locales/ar.d.ts +1 -2
- package/dist/locales/ar.js +0 -1
- package/dist/locales/bn.d.ts +1 -2
- package/dist/locales/bn.js +0 -1
- package/dist/locales/da.d.ts +1 -2
- package/dist/locales/da.js +0 -1
- package/dist/locales/de.d.ts +1 -2
- package/dist/locales/de.js +0 -1
- package/dist/locales/en.d.ts +1 -2
- package/dist/locales/en.js +0 -1
- package/dist/locales/es-MX.d.ts +1 -2
- package/dist/locales/es-MX.js +0 -1
- package/dist/locales/es.d.ts +1 -2
- package/dist/locales/es.js +0 -1
- package/dist/locales/fi.d.ts +1 -2
- package/dist/locales/fi.js +0 -1
- package/dist/locales/fr.d.ts +1 -2
- package/dist/locales/fr.js +0 -1
- package/dist/locales/hi.d.ts +1 -2
- package/dist/locales/hi.js +0 -1
- package/dist/locales/id.d.ts +1 -2
- package/dist/locales/id.js +0 -1
- package/dist/locales/index.d.ts +10 -15
- package/dist/locales/index.js +28 -2
- package/dist/locales/it.d.ts +1 -2
- package/dist/locales/it.js +0 -1
- package/dist/locales/ja.d.ts +1 -2
- package/dist/locales/ja.js +0 -1
- package/dist/locales/ko.d.ts +1 -2
- package/dist/locales/ko.js +0 -1
- package/dist/locales/lazy.d.ts +4 -26
- package/dist/locales/lazy.js +12 -55
- package/dist/locales/nl.d.ts +1 -2
- package/dist/locales/nl.js +0 -1
- package/dist/locales/no.d.ts +1 -2
- package/dist/locales/no.js +0 -1
- package/dist/locales/pl.d.ts +1 -2
- package/dist/locales/pl.js +0 -1
- package/dist/locales/pt-BR.d.ts +1 -2
- package/dist/locales/pt-BR.js +0 -1
- package/dist/locales/pt.d.ts +1 -2
- package/dist/locales/pt.js +0 -1
- package/dist/locales/ru.d.ts +1 -2
- package/dist/locales/ru.js +0 -1
- package/dist/locales/runtime.d.ts +10 -0
- package/dist/locales/runtime.js +41 -0
- package/dist/locales/sv.d.ts +1 -2
- package/dist/locales/sv.js +0 -1
- package/dist/locales/sw.d.ts +1 -2
- package/dist/locales/sw.js +0 -1
- package/dist/locales/th.d.ts +1 -2
- package/dist/locales/th.js +0 -1
- package/dist/locales/tr.d.ts +1 -2
- package/dist/locales/tr.js +0 -1
- package/dist/locales/types.d.ts +0 -1
- package/dist/locales/vi.d.ts +1 -2
- package/dist/locales/vi.js +0 -1
- package/dist/locales/zh.d.ts +1 -2
- package/dist/locales/zh.js +0 -1
- package/dist/logger.d.ts +0 -1
- package/dist/mini.d.ts +64 -65
- package/dist/mini.js +31 -7
- package/dist/pigment.d.ts +0 -1
- package/dist/pigment.js +6 -4
- package/dist/plugins/index.d.ts +2 -3
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/types.d.ts +4 -5
- package/dist/registry.d.ts +23 -0
- package/dist/registry.js +34 -0
- package/dist/utils/codec-utils.d.ts +0 -1
- package/dist/utils/deep-merge.d.ts +0 -1
- package/dist/utils/ip-validation.d.ts +0 -1
- package/dist/utils/json-schema.d.ts +77 -0
- package/dist/utils/security.d.ts +2 -6
- package/dist/v3/index.d.ts +2 -0
- package/dist/v3/index.js +46 -0
- package/dist/v4/core/index.d.ts +260 -0
- package/dist/v4/core/index.js +277 -0
- package/dist/v4/index.d.ts +4 -0
- package/dist/v4/index.js +50 -0
- package/dist/v4/locales/index.d.ts +53 -0
- package/dist/v4/locales/index.js +77 -0
- package/dist/v4/mini/index.d.ts +2 -0
- package/dist/v4/mini/index.js +47 -0
- package/dist/v4-mini/index.d.ts +22 -0
- package/dist/v4-mini/index.js +75 -0
- package/dist/validators/any.d.ts +7 -2
- package/dist/validators/any.js +37 -0
- package/dist/validators/array.d.ts +9 -2
- package/dist/validators/array.js +279 -0
- package/dist/validators/base.d.ts +228 -5
- package/dist/validators/base.js +868 -0
- package/dist/validators/base64.d.ts +1 -2
- package/dist/validators/base64.js +68 -0
- package/dist/validators/bigint.d.ts +21 -3
- package/dist/validators/bigint.js +228 -0
- package/dist/validators/boolean.d.ts +13 -4
- package/dist/validators/boolean.js +142 -0
- package/dist/validators/codec.d.ts +9 -2
- package/dist/validators/codec.js +200 -0
- package/dist/validators/custom.d.ts +15 -2
- package/dist/validators/custom.js +67 -0
- package/dist/validators/date.d.ts +19 -3
- package/dist/validators/date.js +274 -0
- package/dist/validators/discriminated-union.d.ts +4 -3
- package/dist/validators/discriminated-union.js +123 -0
- package/dist/validators/enum.d.ts +10 -7
- package/dist/validators/enum.js +150 -0
- package/dist/validators/file.d.ts +7 -2
- package/dist/validators/file.js +125 -0
- package/dist/validators/function.d.ts +11 -5
- package/dist/validators/function.js +58 -0
- package/dist/validators/hex.d.ts +1 -2
- package/dist/validators/hex.js +65 -0
- package/dist/validators/index.d.ts +38 -38
- package/dist/validators/index.js +35 -5
- package/dist/validators/intersection.d.ts +1 -2
- package/dist/validators/intersection.js +116 -0
- package/dist/validators/json.d.ts +1 -2
- package/dist/validators/json.js +66 -0
- package/dist/validators/lazy.d.ts +5 -9
- package/dist/validators/lazy.js +50 -0
- package/dist/validators/literal.d.ts +2 -2
- package/dist/validators/literal.js +60 -0
- package/dist/validators/map.d.ts +15 -2
- package/dist/validators/map.js +214 -0
- package/dist/validators/nan.d.ts +2 -3
- package/dist/validators/nan.js +38 -0
- package/dist/validators/never.d.ts +1 -2
- package/dist/validators/never.js +32 -0
- package/dist/validators/null.d.ts +3 -3
- package/dist/validators/null.js +40 -0
- package/dist/validators/number.d.ts +80 -21
- package/dist/validators/number.js +423 -0
- package/dist/validators/object.d.ts +30 -9
- package/dist/validators/object.js +864 -0
- package/dist/validators/promise.d.ts +58 -0
- package/dist/validators/promise.js +111 -0
- package/dist/validators/record.d.ts +11 -2
- package/dist/validators/record.js +258 -0
- package/dist/validators/set.d.ts +11 -2
- package/dist/validators/set.js +199 -0
- package/dist/validators/string-bool.d.ts +7 -10
- package/dist/validators/string-bool.js +120 -0
- package/dist/validators/string-formats.d.ts +13 -4
- package/dist/validators/string-formats.js +135 -0
- package/dist/validators/string.d.ts +39 -18
- package/dist/validators/string.js +4 -0
- package/dist/validators/symbol.d.ts +8 -3
- package/dist/validators/symbol.js +58 -0
- package/dist/validators/template-literal.d.ts +1 -2
- package/dist/validators/template-literal.js +103 -0
- package/dist/validators/tuple.d.ts +15 -2
- package/dist/validators/tuple.js +183 -0
- package/dist/validators/uint8array.d.ts +3 -4
- package/dist/validators/uint8array.js +101 -0
- package/dist/validators/undefined.d.ts +3 -3
- package/dist/validators/undefined.js +40 -0
- package/dist/validators/union.d.ts +7 -4
- package/dist/validators/union.js +187 -0
- package/dist/validators/unknown.d.ts +7 -2
- package/dist/{chunks/unknown-SLIH1VCf.js → validators/unknown.js} +12 -3
- package/dist/validators/void.d.ts +3 -2
- package/dist/validators/void.js +44 -0
- package/dist/validators/xor.d.ts +2 -3
- package/dist/validators/xor.js +66 -0
- package/package.json +116 -31
- package/dist/chunks/bigint-DgsCr2dC.js +0 -1709
- package/dist/chunks/bigint-DgsCr2dC.js.map +0 -1
- package/dist/chunks/date-ODue_rtq.js.map +0 -1
- package/dist/chunks/index-BZqWZvVe.js +0 -426
- package/dist/chunks/index-BZqWZvVe.js.map +0 -1
- package/dist/chunks/index-CETyGkrv.js.map +0 -1
- package/dist/chunks/json-o20GFhTh.js +0 -2021
- package/dist/chunks/json-o20GFhTh.js.map +0 -1
- package/dist/chunks/unknown-SLIH1VCf.js.map +0 -1
- package/dist/cjs/errors.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/locales/index.cjs.map +0 -1
- package/dist/cjs/locales/lazy.cjs.map +0 -1
- package/dist/cjs/mini.cjs.map +0 -1
- package/dist/cli/bin.d.ts.map +0 -1
- package/dist/cli/commands/benchmark.d.ts.map +0 -1
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/codecs/index.d.ts.map +0 -1
- package/dist/codecs/index.js.map +0 -1
- package/dist/coercion/bigint.d.ts.map +0 -1
- package/dist/coercion/boolean.d.ts.map +0 -1
- package/dist/coercion/date.d.ts.map +0 -1
- package/dist/coercion/index.d.ts.map +0 -1
- package/dist/coercion/index.js.map +0 -1
- package/dist/coercion/number.d.ts.map +0 -1
- package/dist/coercion/string.d.ts.map +0 -1
- package/dist/compat/emitter.d.ts.map +0 -1
- package/dist/compat/emitter.js.map +0 -1
- package/dist/compat/index.d.ts.map +0 -1
- package/dist/compat/result.d.ts.map +0 -1
- package/dist/compat/result.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/locales/af.d.ts.map +0 -1
- package/dist/locales/af.js.map +0 -1
- package/dist/locales/ar.d.ts.map +0 -1
- package/dist/locales/ar.js.map +0 -1
- package/dist/locales/backup-en.d.ts +0 -3
- package/dist/locales/backup-en.d.ts.map +0 -1
- package/dist/locales/bn.d.ts.map +0 -1
- package/dist/locales/bn.js.map +0 -1
- package/dist/locales/da.d.ts.map +0 -1
- package/dist/locales/da.js.map +0 -1
- package/dist/locales/de.d.ts.map +0 -1
- package/dist/locales/de.js.map +0 -1
- package/dist/locales/en.d.ts.map +0 -1
- package/dist/locales/en.js.map +0 -1
- package/dist/locales/es-MX.d.ts.map +0 -1
- package/dist/locales/es-MX.js.map +0 -1
- package/dist/locales/es.d.ts.map +0 -1
- package/dist/locales/es.js.map +0 -1
- package/dist/locales/fi.d.ts.map +0 -1
- package/dist/locales/fi.js.map +0 -1
- package/dist/locales/fr.d.ts.map +0 -1
- package/dist/locales/fr.js.map +0 -1
- package/dist/locales/hi.d.ts.map +0 -1
- package/dist/locales/hi.js.map +0 -1
- package/dist/locales/id.d.ts.map +0 -1
- package/dist/locales/id.js.map +0 -1
- package/dist/locales/index.d.ts.map +0 -1
- package/dist/locales/index.js.map +0 -1
- package/dist/locales/it.d.ts.map +0 -1
- package/dist/locales/it.js.map +0 -1
- package/dist/locales/ja.d.ts.map +0 -1
- package/dist/locales/ja.js.map +0 -1
- package/dist/locales/ko.d.ts.map +0 -1
- package/dist/locales/ko.js.map +0 -1
- package/dist/locales/lazy.d.ts.map +0 -1
- package/dist/locales/lazy.js.map +0 -1
- package/dist/locales/nl.d.ts.map +0 -1
- package/dist/locales/nl.js.map +0 -1
- package/dist/locales/no.d.ts.map +0 -1
- package/dist/locales/no.js.map +0 -1
- package/dist/locales/pl.d.ts.map +0 -1
- package/dist/locales/pl.js.map +0 -1
- package/dist/locales/pt-BR.d.ts.map +0 -1
- package/dist/locales/pt-BR.js.map +0 -1
- package/dist/locales/pt.d.ts.map +0 -1
- package/dist/locales/pt.js.map +0 -1
- package/dist/locales/ru.d.ts.map +0 -1
- package/dist/locales/ru.js.map +0 -1
- package/dist/locales/sv.d.ts.map +0 -1
- package/dist/locales/sv.js.map +0 -1
- package/dist/locales/sw.d.ts.map +0 -1
- package/dist/locales/sw.js.map +0 -1
- package/dist/locales/th.d.ts.map +0 -1
- package/dist/locales/th.js.map +0 -1
- package/dist/locales/tr.d.ts.map +0 -1
- package/dist/locales/tr.js.map +0 -1
- package/dist/locales/types.d.ts.map +0 -1
- package/dist/locales/vi.d.ts.map +0 -1
- package/dist/locales/vi.js.map +0 -1
- package/dist/locales/zh.d.ts.map +0 -1
- package/dist/locales/zh.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mini.d.ts.map +0 -1
- package/dist/mini.js.map +0 -1
- package/dist/pigment.d.ts.map +0 -1
- package/dist/pigment.js.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/utils/codec-utils.d.ts.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/ip-validation.d.ts.map +0 -1
- package/dist/utils/security.d.ts.map +0 -1
- package/dist/validators/any.d.ts.map +0 -1
- package/dist/validators/array.d.ts.map +0 -1
- package/dist/validators/base.d.ts.map +0 -1
- package/dist/validators/base64.d.ts.map +0 -1
- package/dist/validators/bigint.d.ts.map +0 -1
- package/dist/validators/boolean.d.ts.map +0 -1
- package/dist/validators/codec.d.ts.map +0 -1
- package/dist/validators/custom.d.ts.map +0 -1
- package/dist/validators/date.d.ts.map +0 -1
- package/dist/validators/discriminated-union.d.ts.map +0 -1
- package/dist/validators/enum.d.ts.map +0 -1
- package/dist/validators/file.d.ts.map +0 -1
- package/dist/validators/function.d.ts.map +0 -1
- package/dist/validators/hex.d.ts.map +0 -1
- package/dist/validators/index.d.ts.map +0 -1
- package/dist/validators/index.js.map +0 -1
- package/dist/validators/intersection.d.ts.map +0 -1
- package/dist/validators/json.d.ts.map +0 -1
- package/dist/validators/lazy.d.ts.map +0 -1
- package/dist/validators/literal.d.ts.map +0 -1
- package/dist/validators/map.d.ts.map +0 -1
- package/dist/validators/nan.d.ts.map +0 -1
- package/dist/validators/never.d.ts.map +0 -1
- package/dist/validators/null.d.ts.map +0 -1
- package/dist/validators/number.d.ts.map +0 -1
- package/dist/validators/object.d.ts.map +0 -1
- package/dist/validators/record.d.ts.map +0 -1
- package/dist/validators/set.d.ts.map +0 -1
- package/dist/validators/string-bool.d.ts.map +0 -1
- package/dist/validators/string-formats.d.ts.map +0 -1
- package/dist/validators/string.d.ts.map +0 -1
- package/dist/validators/symbol.d.ts.map +0 -1
- package/dist/validators/template-literal.d.ts.map +0 -1
- package/dist/validators/tuple.d.ts.map +0 -1
- package/dist/validators/uint8array.d.ts.map +0 -1
- package/dist/validators/undefined.d.ts.map +0 -1
- package/dist/validators/union.d.ts.map +0 -1
- package/dist/validators/unknown.d.ts.map +0 -1
- package/dist/validators/void.d.ts.map +0 -1
- package/dist/validators/xor.d.ts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VldBase, ParseResult } from './base';
|
|
1
|
+
import { VldBase, ParseResult } from './base.js';
|
|
2
2
|
/**
|
|
3
3
|
* Configuration for string boolean validation
|
|
4
4
|
*/
|
|
@@ -16,6 +16,11 @@ export interface StringBoolOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
export declare class VldStringBool extends VldBase<unknown, boolean> {
|
|
18
18
|
private readonly options;
|
|
19
|
+
private readonly truthyValues;
|
|
20
|
+
private readonly falsyValues;
|
|
21
|
+
private readonly normalizedTruthySet;
|
|
22
|
+
private readonly normalizedFalsySet;
|
|
23
|
+
private readonly validValuesText;
|
|
19
24
|
private constructor();
|
|
20
25
|
/**
|
|
21
26
|
* Create a new string boolean validator
|
|
@@ -25,14 +30,7 @@ export declare class VldStringBool extends VldBase<unknown, boolean> {
|
|
|
25
30
|
* Normalize a string value based on case sensitivity setting
|
|
26
31
|
*/
|
|
27
32
|
private normalizeValue;
|
|
28
|
-
|
|
29
|
-
* Get the effective truthy values (custom or default)
|
|
30
|
-
*/
|
|
31
|
-
private getTruthyValues;
|
|
32
|
-
/**
|
|
33
|
-
* Get the effective falsy values (custom or default)
|
|
34
|
-
*/
|
|
35
|
-
private getFalsyValues;
|
|
33
|
+
private normalizeValues;
|
|
36
34
|
/**
|
|
37
35
|
* Parse and validate a string boolean value
|
|
38
36
|
*/
|
|
@@ -58,4 +56,3 @@ export declare class VldStringBool extends VldBase<unknown, boolean> {
|
|
|
58
56
|
*/
|
|
59
57
|
caseInsensitive(): VldStringBool;
|
|
60
58
|
}
|
|
61
|
-
//# sourceMappingURL=string-bool.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
|
|
2
|
+
import { getMessages } from '../locales/runtime.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Default truthy and falsy value sets
|
|
6
|
+
*/
|
|
7
|
+
const DEFAULT_TRUTHY = ['true', '1', 'yes', 'on', 'y', 'enabled'];
|
|
8
|
+
const DEFAULT_FALSY = ['false', '0', 'no', 'off', 'n', 'disabled'];
|
|
9
|
+
/**
|
|
10
|
+
* Immutable string boolean validator for flexible boolean parsing
|
|
11
|
+
* Supports string representations like "true", "yes", "on", "1", etc.
|
|
12
|
+
*/
|
|
13
|
+
class VldStringBool extends VldBase {
|
|
14
|
+
constructor(options) {
|
|
15
|
+
super(VLD_VALIDATOR_TYPES.STRING_BOOL);
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.truthyValues = options.truthy ?? DEFAULT_TRUTHY;
|
|
18
|
+
this.falsyValues = options.falsy ?? DEFAULT_FALSY;
|
|
19
|
+
const normalizedTruthy = this.normalizeValues(this.truthyValues);
|
|
20
|
+
const normalizedFalsy = this.normalizeValues(this.falsyValues);
|
|
21
|
+
this.normalizedTruthySet = new Set(normalizedTruthy);
|
|
22
|
+
this.normalizedFalsySet = new Set(normalizedFalsy);
|
|
23
|
+
this.validValuesText = [...normalizedTruthy, ...normalizedFalsy].join(', ');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a new string boolean validator
|
|
27
|
+
*/
|
|
28
|
+
static create(options = {}) {
|
|
29
|
+
return new VldStringBool(options);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Normalize a string value based on case sensitivity setting
|
|
33
|
+
*/
|
|
34
|
+
normalizeValue(value) {
|
|
35
|
+
return this.options.caseSensitive ? value : value.toLowerCase();
|
|
36
|
+
}
|
|
37
|
+
normalizeValues(values) {
|
|
38
|
+
if (this.options.caseSensitive) {
|
|
39
|
+
return values;
|
|
40
|
+
}
|
|
41
|
+
return values.map(value => value.toLowerCase());
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse and validate a string boolean value
|
|
45
|
+
*/
|
|
46
|
+
parse(value) {
|
|
47
|
+
// First, ensure we have a string
|
|
48
|
+
if (typeof value !== 'string') {
|
|
49
|
+
// Also accept actual boolean values for convenience
|
|
50
|
+
if (typeof value === 'boolean') {
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
throw new Error(getMessages().stringExpected(typeof value, 'string'));
|
|
54
|
+
}
|
|
55
|
+
const normalized = this.normalizeValue(value);
|
|
56
|
+
// Check if value is in truthy set
|
|
57
|
+
if (this.normalizedTruthySet.has(normalized)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
// Check if value is in falsy set
|
|
61
|
+
if (this.normalizedFalsySet.has(normalized)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// Value is not recognized
|
|
65
|
+
throw new Error(getMessages().stringBoolExpected(this.validValuesText, value));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Safely parse and validate a string boolean value
|
|
69
|
+
*/
|
|
70
|
+
safeParse(value) {
|
|
71
|
+
try {
|
|
72
|
+
const result = this.parse(value);
|
|
73
|
+
return { success: true, data: result };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
return {
|
|
77
|
+
success: false,
|
|
78
|
+
error: error
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a new validator with custom truthy values
|
|
84
|
+
*/
|
|
85
|
+
withTruthy(values) {
|
|
86
|
+
return new VldStringBool({
|
|
87
|
+
...this.options,
|
|
88
|
+
truthy: values
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a new validator with custom falsy values
|
|
93
|
+
*/
|
|
94
|
+
withFalsy(values) {
|
|
95
|
+
return new VldStringBool({
|
|
96
|
+
...this.options,
|
|
97
|
+
falsy: values
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new validator with case-sensitive matching
|
|
102
|
+
*/
|
|
103
|
+
caseSensitive() {
|
|
104
|
+
return new VldStringBool({
|
|
105
|
+
...this.options,
|
|
106
|
+
caseSensitive: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Create a new validator with case-insensitive matching (default)
|
|
111
|
+
*/
|
|
112
|
+
caseInsensitive() {
|
|
113
|
+
return new VldStringBool({
|
|
114
|
+
...this.options,
|
|
115
|
+
caseSensitive: false
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export { VldStringBool };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Part of Zod 4 API parity implementation
|
|
4
4
|
* Provides convenient validators for common string formats
|
|
5
5
|
*/
|
|
6
|
-
import { VldBase } from './base';
|
|
7
|
-
import type { ParseResult } from './base';
|
|
6
|
+
import { VldBase } from './base.js';
|
|
7
|
+
import type { ParseResult } from './base.js';
|
|
8
8
|
/**
|
|
9
9
|
* Pre-compiled regex patterns for performance
|
|
10
10
|
*/
|
|
@@ -38,11 +38,15 @@ declare const REGEXES: {
|
|
|
38
38
|
readonly sha256: RegExp;
|
|
39
39
|
readonly sha384: RegExp;
|
|
40
40
|
readonly sha512: RegExp;
|
|
41
|
+
readonly xid: RegExp;
|
|
42
|
+
readonly guid: RegExp;
|
|
43
|
+
readonly httpUrl: RegExp;
|
|
44
|
+
readonly ksuid: RegExp;
|
|
41
45
|
};
|
|
42
46
|
/**
|
|
43
47
|
* Generic string format validator
|
|
44
48
|
*/
|
|
45
|
-
declare class VldStringFormat extends VldBase<unknown, string> {
|
|
49
|
+
export declare class VldStringFormat extends VldBase<unknown, string> {
|
|
46
50
|
readonly _format: string;
|
|
47
51
|
readonly _validator: (val: string) => boolean;
|
|
48
52
|
readonly _errorMessage?: string | undefined;
|
|
@@ -61,6 +65,8 @@ export declare const uuid: (options?: {
|
|
|
61
65
|
version?: "v4" | "v6" | "v7";
|
|
62
66
|
}) => VldStringFormat;
|
|
63
67
|
export declare const uuidv4: () => VldStringFormat;
|
|
68
|
+
export declare const uuidv6: () => VldStringFormat;
|
|
69
|
+
export declare const uuidv7: () => VldStringFormat;
|
|
64
70
|
export declare const hostname: () => VldStringFormat;
|
|
65
71
|
export declare const emoji: () => VldStringFormat;
|
|
66
72
|
export declare const base64: () => VldStringFormat;
|
|
@@ -77,6 +83,10 @@ export declare const mac: () => VldStringFormat;
|
|
|
77
83
|
export declare const cidrv4: () => VldStringFormat;
|
|
78
84
|
export declare const cidrv6: () => VldStringFormat;
|
|
79
85
|
export declare const e164: () => VldStringFormat;
|
|
86
|
+
export declare const xid: () => VldStringFormat;
|
|
87
|
+
export declare const guid: () => VldStringFormat;
|
|
88
|
+
export declare const httpUrl: () => VldStringFormat;
|
|
89
|
+
export declare const ksuid: () => VldStringFormat;
|
|
80
90
|
export declare const hash: (algorithm: "md5" | "sha1" | "sha256" | "sha384" | "sha512") => VldStringFormat;
|
|
81
91
|
/**
|
|
82
92
|
* ISO date/time validators
|
|
@@ -94,4 +104,3 @@ export declare const iso: {
|
|
|
94
104
|
*/
|
|
95
105
|
export declare const stringFormat: (name: string, validator: ((val: string) => boolean) | RegExp) => VldStringFormat;
|
|
96
106
|
export { REGEXES as regexes };
|
|
97
|
-
//# sourceMappingURL=string-formats.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
|
|
2
|
+
import { getMessages } from '../locales/runtime.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Top-level string format validators
|
|
6
|
+
* Part of Zod 4 API parity implementation
|
|
7
|
+
* Provides convenient validators for common string formats
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Pre-compiled regex patterns for performance
|
|
11
|
+
*/
|
|
12
|
+
const REGEXES = {
|
|
13
|
+
email: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
|
|
14
|
+
uuid: /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,
|
|
15
|
+
uuidv4: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
16
|
+
uuidv6: /^[0-9a-f]{8}-[0-9a-f]{4}-6[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
17
|
+
uuidv7: /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,
|
|
18
|
+
hostname: /^(?=.{1,253}$)(?:(?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$/,
|
|
19
|
+
emoji: /^(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F)(?:\u200D(?:\p{Emoji_Presentation}|\p{Emoji}\uFE0F))*$/u,
|
|
20
|
+
base64: /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,
|
|
21
|
+
base64url: /^[A-Za-z0-9_-]*$/,
|
|
22
|
+
hex: /^[0-9a-fA-F]*$/,
|
|
23
|
+
jwt: /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$/,
|
|
24
|
+
nanoid: /^[A-Za-z0-9_-]{21}$/,
|
|
25
|
+
cuid: /^c[^\s-]{8,}$/i,
|
|
26
|
+
cuid2: /^[0-9a-z]+$/,
|
|
27
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
28
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
|
|
29
|
+
ipv6: /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/,
|
|
30
|
+
mac: /^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$/,
|
|
31
|
+
cidrv4: /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/(?:3[0-2]|[12]?[0-9])$/,
|
|
32
|
+
cidrv6: /^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$|^(?:[0-9a-fA-F]{1,4}:){1,7}:\/(?:12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
33
|
+
e164: /^\+[1-9]\d{1,14}$/,
|
|
34
|
+
isoDate: /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])$/,
|
|
35
|
+
isoTime: /^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d+)?)?$/,
|
|
36
|
+
isoDateTime: /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?Z?$/,
|
|
37
|
+
md5: /^[a-f0-9]{32}$/i,
|
|
38
|
+
sha1: /^[a-f0-9]{40}$/i,
|
|
39
|
+
sha256: /^[a-f0-9]{64}$/i,
|
|
40
|
+
sha384: /^[a-f0-9]{96}$/i,
|
|
41
|
+
sha512: /^[a-f0-9]{128}$/i,
|
|
42
|
+
// Additional formats (Zod v4 parity)
|
|
43
|
+
xid: /^[A-HJKMNP-TV-Z0-9]{20}$/, // ksort's XID format
|
|
44
|
+
guid: /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/i, // Alias for UUID
|
|
45
|
+
httpUrl: /^https?:\/\/[^\s/$.?#].[^\s]*$/, // HTTP/HTTPS URL
|
|
46
|
+
ksuid: /^[0-9A-Za-z]{27}$/,
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Generic string format validator
|
|
50
|
+
*/
|
|
51
|
+
class VldStringFormat extends VldBase {
|
|
52
|
+
constructor(_format, _validator, _errorMessage) {
|
|
53
|
+
super(VLD_VALIDATOR_TYPES.STRING_FORMAT);
|
|
54
|
+
this._format = _format;
|
|
55
|
+
this._validator = _validator;
|
|
56
|
+
this._errorMessage = _errorMessage;
|
|
57
|
+
}
|
|
58
|
+
static create(format, validator, errorMessage) {
|
|
59
|
+
return new VldStringFormat(format, validator, errorMessage);
|
|
60
|
+
}
|
|
61
|
+
parse(value) {
|
|
62
|
+
if (typeof value !== 'string') {
|
|
63
|
+
throw new Error(getMessages().invalidString);
|
|
64
|
+
}
|
|
65
|
+
if (!this._validator(value)) {
|
|
66
|
+
throw new Error(this._errorMessage || `Invalid ${this._format} format`);
|
|
67
|
+
}
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
safeParse(value) {
|
|
71
|
+
if (typeof value !== 'string') {
|
|
72
|
+
return {
|
|
73
|
+
success: false,
|
|
74
|
+
error: new Error(getMessages().invalidString)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
if (!this._validator(value)) {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: new Error(this._errorMessage || `Invalid ${this._format} format`)
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { success: true, data: value };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Top-level string format validators
|
|
88
|
+
*/
|
|
89
|
+
const email = (options) => VldStringFormat.create('email', (val) => (options?.pattern ?? REGEXES.email).test(val));
|
|
90
|
+
const uuid = (options) => {
|
|
91
|
+
const pattern = options?.version ? REGEXES[`uuid${options.version}`] : REGEXES.uuid;
|
|
92
|
+
return VldStringFormat.create('uuid', (val) => pattern.test(val));
|
|
93
|
+
};
|
|
94
|
+
const uuidv4 = () => VldStringFormat.create('uuid', (val) => REGEXES.uuidv4.test(val));
|
|
95
|
+
const uuidv6 = () => VldStringFormat.create('uuid', (val) => REGEXES.uuidv6.test(val));
|
|
96
|
+
const uuidv7 = () => VldStringFormat.create('uuid', (val) => REGEXES.uuidv7.test(val));
|
|
97
|
+
const hostname = () => VldStringFormat.create('hostname', (val) => REGEXES.hostname.test(val));
|
|
98
|
+
const emoji = () => VldStringFormat.create('emoji', (val) => REGEXES.emoji.test(val));
|
|
99
|
+
const base64 = () => VldStringFormat.create('base64', (val) => REGEXES.base64.test(val));
|
|
100
|
+
const base64url = () => VldStringFormat.create('base64url', (val) => REGEXES.base64url.test(val));
|
|
101
|
+
const hex = () => VldStringFormat.create('hex', (val) => REGEXES.hex.test(val));
|
|
102
|
+
const jwt = () => VldStringFormat.create('jwt', (val) => REGEXES.jwt.test(val));
|
|
103
|
+
const nanoid = () => VldStringFormat.create('nanoid', (val) => REGEXES.nanoid.test(val));
|
|
104
|
+
const cuid = () => VldStringFormat.create('cuid', (val) => REGEXES.cuid.test(val));
|
|
105
|
+
const cuid2 = () => VldStringFormat.create('cuid2', (val) => REGEXES.cuid2.test(val));
|
|
106
|
+
const ulid = () => VldStringFormat.create('ulid', (val) => REGEXES.ulid.test(val));
|
|
107
|
+
const ipv4 = () => VldStringFormat.create('ipv4', (val) => REGEXES.ipv4.test(val));
|
|
108
|
+
const ipv6 = () => VldStringFormat.create('ipv6', (val) => REGEXES.ipv6.test(val));
|
|
109
|
+
const mac = () => VldStringFormat.create('mac', (val) => REGEXES.mac.test(val));
|
|
110
|
+
const cidrv4 = () => VldStringFormat.create('cidrv4', (val) => REGEXES.cidrv4.test(val));
|
|
111
|
+
const cidrv6 = () => VldStringFormat.create('cidrv6', (val) => REGEXES.cidrv6.test(val));
|
|
112
|
+
const e164 = () => VldStringFormat.create('e164', (val) => REGEXES.e164.test(val));
|
|
113
|
+
const xid = () => VldStringFormat.create('xid', (val) => REGEXES.xid.test(val));
|
|
114
|
+
const guid = () => VldStringFormat.create('guid', (val) => REGEXES.guid.test(val));
|
|
115
|
+
const httpUrl = () => VldStringFormat.create('httpUrl', (val) => REGEXES.httpUrl.test(val));
|
|
116
|
+
const ksuid = () => VldStringFormat.create('ksuid', (val) => REGEXES.ksuid.test(val));
|
|
117
|
+
const hash = (algorithm) => VldStringFormat.create('hash', (val) => REGEXES[algorithm]?.test(val) ?? false, `Invalid ${algorithm} hash`);
|
|
118
|
+
/**
|
|
119
|
+
* ISO date/time validators
|
|
120
|
+
*/
|
|
121
|
+
const iso = {
|
|
122
|
+
date: () => VldStringFormat.create('date', (val) => REGEXES.isoDate.test(val)),
|
|
123
|
+
time: () => VldStringFormat.create('time', (val) => REGEXES.isoTime.test(val)),
|
|
124
|
+
dateTime: (_options) => VldStringFormat.create('datetime', (val) => REGEXES.isoDateTime.test(val)),
|
|
125
|
+
duration: () => VldStringFormat.create('duration', (val) => /^-?P(?!$)(?:\d+(?:\.\d+)?Y)?(?:\d+(?:\.\d+)?M)?(?:\d+(?:\.\d+)?W)?(?:\d+(?:\.\d+)?D)?(?:T(?=\d)(?:\d+(?:\.\d+)?H)?(?:\d+(?:\.\d+)?M)?(?:\d+(?:\.\d+)?S)?)?$/.test(val)),
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Custom format validator
|
|
129
|
+
*/
|
|
130
|
+
const stringFormat = (name, validator) => {
|
|
131
|
+
const fn = validator instanceof RegExp ? (val) => validator.test(val) : validator;
|
|
132
|
+
return VldStringFormat.create(name, fn);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export { VldStringFormat, base64, base64url, cidrv4, cidrv6, cuid, cuid2, e164, email, emoji, guid, hash, hex, hostname, httpUrl, ipv4, ipv6, iso, jwt, ksuid, mac, nanoid, REGEXES as regexes, stringFormat, ulid, uuid, uuidv4, uuidv6, uuidv7, xid };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VldBase, ParseResult } from './base';
|
|
1
|
+
import { VldBase, ParseResult, ValidatorType, type ErrorParam } from './base.js';
|
|
2
2
|
/**
|
|
3
3
|
* Type for string validation check functions
|
|
4
4
|
*/
|
|
@@ -7,13 +7,22 @@ type StringCheck = (value: string) => boolean;
|
|
|
7
7
|
* Type for string transformation functions
|
|
8
8
|
*/
|
|
9
9
|
type StringTransform = (value: string) => string;
|
|
10
|
+
interface StringJSONSchemaHints {
|
|
11
|
+
minLength?: number;
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
exactLength?: number;
|
|
14
|
+
format?: string;
|
|
15
|
+
pattern?: string;
|
|
16
|
+
}
|
|
10
17
|
/**
|
|
11
18
|
* Configuration for string validator
|
|
12
19
|
*/
|
|
13
20
|
interface StringValidatorConfig {
|
|
14
21
|
readonly checks: ReadonlyArray<StringCheck>;
|
|
15
22
|
readonly transforms: ReadonlyArray<StringTransform>;
|
|
16
|
-
readonly errorMessage
|
|
23
|
+
readonly errorMessage: string | undefined;
|
|
24
|
+
readonly validatorType?: ValidatorType;
|
|
25
|
+
readonly jsonSchema: StringJSONSchemaHints | undefined;
|
|
17
26
|
}
|
|
18
27
|
/**
|
|
19
28
|
* Immutable string validator with chainable methods
|
|
@@ -21,6 +30,9 @@ interface StringValidatorConfig {
|
|
|
21
30
|
*/
|
|
22
31
|
export declare class VldString extends VldBase<string, string> {
|
|
23
32
|
protected readonly config: StringValidatorConfig;
|
|
33
|
+
private readonly _checks;
|
|
34
|
+
private readonly _transforms;
|
|
35
|
+
private readonly _isSimple;
|
|
24
36
|
private _compiledValidator;
|
|
25
37
|
/**
|
|
26
38
|
* Protected constructor to allow extension while maintaining immutability
|
|
@@ -35,14 +47,24 @@ export declare class VldString extends VldBase<string, string> {
|
|
|
35
47
|
* Get the cached compiled validator, creating it if necessary
|
|
36
48
|
*/
|
|
37
49
|
private _getCompiledValidator;
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if this is a simple string validator with no transforms or checks
|
|
52
|
+
* Used by VldObject for optimized fast-path dispatch
|
|
53
|
+
*/
|
|
54
|
+
get isSimple(): boolean;
|
|
38
55
|
/**
|
|
39
56
|
* Create a new string validator
|
|
40
57
|
*/
|
|
41
58
|
static create(): VldString;
|
|
42
59
|
/**
|
|
43
|
-
* Parse and validate a string value
|
|
60
|
+
* Parse and validate a string value without allocating intermediate result objects.
|
|
44
61
|
*/
|
|
45
62
|
parse(value: unknown): string;
|
|
63
|
+
/**
|
|
64
|
+
* Parse a value that has already passed the string type guard.
|
|
65
|
+
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
66
|
+
*/
|
|
67
|
+
parseKnownString(value: string): string;
|
|
46
68
|
/**
|
|
47
69
|
* Safely parse and validate a string value
|
|
48
70
|
*/
|
|
@@ -50,31 +72,31 @@ export declare class VldString extends VldBase<string, string> {
|
|
|
50
72
|
/**
|
|
51
73
|
* Create a new validator with minimum length constraint
|
|
52
74
|
*/
|
|
53
|
-
min(length: number, message?:
|
|
75
|
+
min(length: number, message?: ErrorParam): VldString;
|
|
54
76
|
/**
|
|
55
77
|
* Create a new validator with maximum length constraint
|
|
56
78
|
*/
|
|
57
|
-
max(length: number, message?:
|
|
79
|
+
max(length: number, message?: ErrorParam): VldString;
|
|
58
80
|
/**
|
|
59
81
|
* Create a new validator with exact length constraint
|
|
60
82
|
*/
|
|
61
|
-
length(length: number, message?:
|
|
83
|
+
length(length: number, message?: ErrorParam): VldString;
|
|
62
84
|
/**
|
|
63
85
|
* Create a new validator that checks for valid email format
|
|
64
86
|
*/
|
|
65
|
-
email(message?:
|
|
87
|
+
email(message?: ErrorParam): VldString;
|
|
66
88
|
/**
|
|
67
89
|
* Create a new validator that checks for valid URL format
|
|
68
90
|
*/
|
|
69
|
-
url(message?:
|
|
91
|
+
url(message?: ErrorParam): VldString;
|
|
70
92
|
/**
|
|
71
93
|
* Create a new validator that checks for valid UUID format
|
|
72
94
|
*/
|
|
73
|
-
uuid(message?:
|
|
95
|
+
uuid(message?: ErrorParam): VldString;
|
|
74
96
|
/**
|
|
75
97
|
* Create a new validator with regex pattern matching
|
|
76
98
|
*/
|
|
77
|
-
regex(pattern: RegExp, message?:
|
|
99
|
+
regex(pattern: RegExp, message?: ErrorParam): VldString;
|
|
78
100
|
/**
|
|
79
101
|
* Create a new validator that trims whitespace
|
|
80
102
|
*/
|
|
@@ -90,31 +112,30 @@ export declare class VldString extends VldBase<string, string> {
|
|
|
90
112
|
/**
|
|
91
113
|
* Create a new validator that checks if string starts with a substring
|
|
92
114
|
*/
|
|
93
|
-
startsWith(str: string, message?:
|
|
115
|
+
startsWith(str: string, message?: ErrorParam): VldString;
|
|
94
116
|
/**
|
|
95
117
|
* Create a new validator that checks if string ends with a substring
|
|
96
118
|
*/
|
|
97
|
-
endsWith(str: string, message?:
|
|
119
|
+
endsWith(str: string, message?: ErrorParam): VldString;
|
|
98
120
|
/**
|
|
99
121
|
* Create a new validator that checks if string includes a substring
|
|
100
122
|
*/
|
|
101
|
-
includes(str: string, message?:
|
|
123
|
+
includes(str: string, message?: ErrorParam): VldString;
|
|
102
124
|
/**
|
|
103
125
|
* Create a new validator that checks for valid IP address (v4 or v6)
|
|
104
126
|
*/
|
|
105
|
-
ip(message?:
|
|
127
|
+
ip(message?: ErrorParam): VldString;
|
|
106
128
|
/**
|
|
107
129
|
* Create a new validator that checks for valid IPv4 address
|
|
108
130
|
*/
|
|
109
|
-
ipv4(message?:
|
|
131
|
+
ipv4(message?: ErrorParam): VldString;
|
|
110
132
|
/**
|
|
111
133
|
* Create a new validator that checks for valid IPv6 address
|
|
112
134
|
*/
|
|
113
|
-
ipv6(message?:
|
|
135
|
+
ipv6(message?: ErrorParam): VldString;
|
|
114
136
|
/**
|
|
115
137
|
* Create a new validator that ensures string is not empty
|
|
116
138
|
*/
|
|
117
|
-
nonempty(message?:
|
|
139
|
+
nonempty(message?: ErrorParam): VldString;
|
|
118
140
|
}
|
|
119
141
|
export {};
|
|
120
|
-
//# sourceMappingURL=string.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { VldBase, ParseResult } from './base';
|
|
1
|
+
import { VldBase, ParseResult } from './base.js';
|
|
2
2
|
/**
|
|
3
3
|
* Immutable symbol validator
|
|
4
4
|
*/
|
|
5
5
|
export declare class VldSymbol extends VldBase<symbol, symbol> {
|
|
6
|
-
private readonly errorMessage
|
|
6
|
+
private readonly errorMessage;
|
|
7
7
|
/**
|
|
8
8
|
* Private constructor to enforce immutability
|
|
9
9
|
*/
|
|
@@ -12,13 +12,18 @@ export declare class VldSymbol extends VldBase<symbol, symbol> {
|
|
|
12
12
|
* Create a new symbol validator
|
|
13
13
|
*/
|
|
14
14
|
static create(): VldSymbol;
|
|
15
|
+
get isSimple(): boolean;
|
|
15
16
|
/**
|
|
16
17
|
* Parse and validate a symbol value
|
|
17
18
|
*/
|
|
18
19
|
parse(value: unknown): symbol;
|
|
20
|
+
/**
|
|
21
|
+
* Parse a value that has already passed the symbol type guard.
|
|
22
|
+
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
23
|
+
*/
|
|
24
|
+
parseKnownSymbol(value: symbol): symbol;
|
|
19
25
|
/**
|
|
20
26
|
* Safely parse and validate a symbol value
|
|
21
27
|
*/
|
|
22
28
|
safeParse(value: unknown): ParseResult<symbol>;
|
|
23
29
|
}
|
|
24
|
-
//# sourceMappingURL=symbol.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { VldBase, VLD_VALIDATOR_TYPES } from './base.js';
|
|
2
|
+
import { getMessages } from '../locales/runtime.js';
|
|
3
|
+
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
4
|
+
|
|
5
|
+
function createSymbolError(message) {
|
|
6
|
+
return new VldError([{ code: 'invalid_type', path: [], message }]);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Immutable symbol validator
|
|
10
|
+
*/
|
|
11
|
+
class VldSymbol extends VldBase {
|
|
12
|
+
/**
|
|
13
|
+
* Private constructor to enforce immutability
|
|
14
|
+
*/
|
|
15
|
+
constructor(errorMessage) {
|
|
16
|
+
super(VLD_VALIDATOR_TYPES.SYMBOL);
|
|
17
|
+
this.errorMessage = errorMessage;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new symbol validator
|
|
21
|
+
*/
|
|
22
|
+
static create() {
|
|
23
|
+
return new VldSymbol();
|
|
24
|
+
}
|
|
25
|
+
get isSimple() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse and validate a symbol value
|
|
30
|
+
*/
|
|
31
|
+
parse(value) {
|
|
32
|
+
if (typeof value !== 'symbol') {
|
|
33
|
+
throw new Error(this.errorMessage || getMessages().invalidSymbol);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse a value that has already passed the symbol type guard.
|
|
39
|
+
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
40
|
+
*/
|
|
41
|
+
parseKnownSymbol(value) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Safely parse and validate a symbol value
|
|
46
|
+
*/
|
|
47
|
+
safeParse(value) {
|
|
48
|
+
if (typeof value === 'symbol') {
|
|
49
|
+
return { success: true, data: value };
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
success: false,
|
|
53
|
+
error: createSymbolError(this.errorMessage || getMessages().invalidSymbol)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { VldSymbol };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { VldBase, ParseResult } from './base';
|
|
1
|
+
import { VldBase, ParseResult } from './base.js';
|
|
2
2
|
/**
|
|
3
3
|
* Template literal component types
|
|
4
4
|
*/
|
|
@@ -29,4 +29,3 @@ export declare class VldTemplateLiteral extends VldBase<unknown, string> {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function templateLiteral(...components: TLComponent[]): VldTemplateLiteral;
|
|
31
31
|
export {};
|
|
32
|
-
//# sourceMappingURL=template-literal.d.ts.map
|