@oxog/vld 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +75 -1
- package/LICENSE +20 -20
- package/README.md +101 -37
- package/dist/chunks/errors-core-BeiFUtZM.js +81 -0
- package/dist/chunks/{index-CETyGkrv.js → index-0R2ntSud.js} +16 -402
- package/dist/chunks/index-BvH403Yy.js +88 -0
- package/dist/chunks/security-B0Pd_vSY.js +35 -0
- package/dist/chunks/string-BJRQod3t.js +530 -0
- package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +83 -0
- package/dist/cjs/chunks/index-BkI37108.cjs +538 -0
- package/dist/cjs/chunks/index-Cc3bjUMX.cjs +91 -0
- package/dist/cjs/chunks/security-Dc3Jh13T.cjs +37 -0
- package/dist/cjs/chunks/string-BKZrc4hs.cjs +533 -0
- package/dist/cjs/cli/bin.cjs +506 -0
- package/dist/cjs/cli/index.cjs +209 -0
- package/dist/cjs/codecs/index.cjs +45 -0
- package/dist/{chunks/date-ODue_rtq.js → cjs/coercion/index.cjs} +185 -103
- package/dist/cjs/compat/emitter.cjs +184 -0
- package/dist/cjs/compat/result.cjs +189 -0
- package/dist/cjs/errors.cjs +6 -213
- package/dist/cjs/index.cjs +1558 -9647
- package/dist/cjs/kernel.cjs +415 -0
- package/dist/cjs/locales/af.cjs +108 -0
- package/dist/cjs/locales/ar.cjs +108 -0
- package/dist/cjs/locales/bn.cjs +108 -0
- package/dist/cjs/locales/da.cjs +108 -0
- package/dist/cjs/locales/de.cjs +108 -0
- package/dist/cjs/locales/en.cjs +108 -0
- package/dist/cjs/locales/es-MX.cjs +107 -0
- package/dist/cjs/locales/es.cjs +96 -0
- package/dist/cjs/locales/fi.cjs +108 -0
- package/dist/cjs/locales/fr.cjs +96 -0
- package/dist/cjs/locales/hi.cjs +108 -0
- package/dist/cjs/locales/id.cjs +108 -0
- package/dist/cjs/locales/index.cjs +41 -2875
- package/dist/cjs/locales/it.cjs +108 -0
- package/dist/cjs/locales/ja.cjs +108 -0
- package/dist/cjs/locales/ko.cjs +108 -0
- package/dist/cjs/locales/lazy.cjs +42 -3023
- package/dist/cjs/locales/nl.cjs +108 -0
- package/dist/cjs/locales/no.cjs +108 -0
- package/dist/cjs/locales/pl.cjs +108 -0
- package/dist/cjs/locales/pt-BR.cjs +108 -0
- package/dist/cjs/locales/pt.cjs +108 -0
- package/dist/cjs/locales/ru.cjs +108 -0
- package/dist/cjs/locales/runtime.cjs +51 -0
- package/dist/cjs/locales/sv.cjs +108 -0
- package/dist/cjs/locales/sw.cjs +108 -0
- package/dist/cjs/locales/th.cjs +108 -0
- package/dist/cjs/locales/tr.cjs +108 -0
- package/dist/cjs/locales/vi.cjs +108 -0
- package/dist/cjs/locales/zh.cjs +108 -0
- package/dist/cjs/mini.cjs +121 -7208
- package/dist/cjs/pigment.cjs +207 -0
- package/dist/cjs/plugins/index.cjs +12 -0
- package/dist/cjs/registry.cjs +37 -0
- package/dist/cjs/v3/index.cjs +425 -0
- package/dist/cjs/v4/core/index.cjs +894 -0
- package/dist/cjs/v4/index.cjs +425 -0
- package/dist/cjs/v4/locales/index.cjs +130 -0
- package/dist/cjs/v4/mini/index.cjs +509 -0
- package/dist/cjs/v4-mini/index.cjs +532 -0
- package/dist/cjs/validators/any.cjs +40 -0
- package/dist/cjs/validators/array.cjs +283 -0
- package/dist/cjs/validators/base.cjs +887 -0
- package/dist/cjs/validators/base64.cjs +73 -0
- package/dist/cjs/validators/bigint.cjs +232 -0
- package/dist/cjs/validators/boolean.cjs +146 -0
- package/dist/cjs/validators/codec.cjs +205 -0
- package/dist/cjs/validators/custom.cjs +71 -0
- package/dist/cjs/validators/date.cjs +278 -0
- package/dist/cjs/validators/discriminated-union.cjs +130 -0
- package/dist/cjs/validators/enum.cjs +154 -0
- package/dist/cjs/validators/file.cjs +130 -0
- package/dist/cjs/validators/function.cjs +63 -0
- package/dist/cjs/validators/hex.cjs +70 -0
- package/dist/cjs/validators/index.cjs +123 -0
- package/dist/cjs/validators/intersection.cjs +120 -0
- package/dist/cjs/validators/json.cjs +70 -0
- package/dist/cjs/validators/lazy.cjs +53 -0
- package/dist/cjs/validators/literal.cjs +64 -0
- package/dist/cjs/validators/map.cjs +218 -0
- package/dist/cjs/validators/nan.cjs +41 -0
- package/dist/cjs/validators/never.cjs +36 -0
- package/dist/cjs/validators/null.cjs +43 -0
- package/dist/cjs/validators/number.cjs +427 -0
- package/dist/cjs/validators/object.cjs +868 -0
- package/dist/cjs/validators/promise.cjs +115 -0
- package/dist/cjs/validators/record.cjs +262 -0
- package/dist/cjs/validators/set.cjs +203 -0
- package/dist/cjs/validators/string-bool.cjs +124 -0
- package/dist/cjs/validators/string-formats.cjs +168 -0
- package/dist/cjs/validators/string.cjs +12 -0
- package/dist/cjs/validators/symbol.cjs +62 -0
- package/dist/cjs/validators/template-literal.cjs +108 -0
- package/dist/cjs/validators/tuple.cjs +187 -0
- package/dist/cjs/validators/uint8array.cjs +106 -0
- package/dist/cjs/validators/undefined.cjs +43 -0
- package/dist/cjs/validators/union.cjs +191 -0
- package/dist/cjs/validators/unknown.cjs +40 -0
- package/dist/cjs/validators/void.cjs +48 -0
- package/dist/cjs/validators/xor.cjs +69 -0
- package/dist/cli/bin.d.ts +0 -1
- package/dist/cli/bin.js +407 -0
- package/dist/cli/commands/benchmark.d.ts +1 -2
- package/dist/cli/commands/validate.d.ts +1 -2
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +205 -0
- package/dist/codecs/index.d.ts +21 -4
- package/dist/codecs/index.js +11 -4
- package/dist/coercion/bigint.d.ts +2 -3
- package/dist/coercion/boolean.d.ts +3 -3
- package/dist/coercion/date.d.ts +3 -3
- package/dist/coercion/index.d.ts +5 -6
- package/dist/coercion/index.js +473 -5
- package/dist/coercion/number.d.ts +2 -3
- package/dist/coercion/string.d.ts +2 -3
- package/dist/compat/emitter.d.ts +0 -1
- package/dist/compat/emitter.js +0 -1
- package/dist/compat/index.d.ts +4 -5
- package/dist/compat/result.d.ts +1 -2
- package/dist/compat/result.js +0 -1
- package/dist/errors-core.d.ts +39 -0
- package/dist/errors.d.ts +4 -54
- package/dist/errors.js +4 -68
- package/dist/events.d.ts +3 -4
- package/dist/index.d.ts +1195 -600
- package/dist/index.js +1262 -44
- package/dist/kernel.d.ts +2 -3
- package/dist/kernel.js +10 -6
- package/dist/locales/af.d.ts +1 -2
- package/dist/locales/af.js +0 -1
- package/dist/locales/ar.d.ts +1 -2
- package/dist/locales/ar.js +0 -1
- package/dist/locales/bn.d.ts +1 -2
- package/dist/locales/bn.js +0 -1
- package/dist/locales/da.d.ts +1 -2
- package/dist/locales/da.js +0 -1
- package/dist/locales/de.d.ts +1 -2
- package/dist/locales/de.js +0 -1
- package/dist/locales/en.d.ts +1 -2
- package/dist/locales/en.js +0 -1
- package/dist/locales/es-MX.d.ts +1 -2
- package/dist/locales/es-MX.js +0 -1
- package/dist/locales/es.d.ts +1 -2
- package/dist/locales/es.js +0 -1
- package/dist/locales/fi.d.ts +1 -2
- package/dist/locales/fi.js +0 -1
- package/dist/locales/fr.d.ts +1 -2
- package/dist/locales/fr.js +0 -1
- package/dist/locales/hi.d.ts +1 -2
- package/dist/locales/hi.js +0 -1
- package/dist/locales/id.d.ts +1 -2
- package/dist/locales/id.js +0 -1
- package/dist/locales/index.d.ts +10 -15
- package/dist/locales/index.js +28 -2
- package/dist/locales/it.d.ts +1 -2
- package/dist/locales/it.js +0 -1
- package/dist/locales/ja.d.ts +1 -2
- package/dist/locales/ja.js +0 -1
- package/dist/locales/ko.d.ts +1 -2
- package/dist/locales/ko.js +0 -1
- package/dist/locales/lazy.d.ts +4 -26
- package/dist/locales/lazy.js +12 -55
- package/dist/locales/nl.d.ts +1 -2
- package/dist/locales/nl.js +0 -1
- package/dist/locales/no.d.ts +1 -2
- package/dist/locales/no.js +0 -1
- package/dist/locales/pl.d.ts +1 -2
- package/dist/locales/pl.js +0 -1
- package/dist/locales/pt-BR.d.ts +1 -2
- package/dist/locales/pt-BR.js +0 -1
- package/dist/locales/pt.d.ts +1 -2
- package/dist/locales/pt.js +0 -1
- package/dist/locales/ru.d.ts +1 -2
- package/dist/locales/ru.js +0 -1
- package/dist/locales/runtime.d.ts +10 -0
- package/dist/locales/runtime.js +41 -0
- package/dist/locales/sv.d.ts +1 -2
- package/dist/locales/sv.js +0 -1
- package/dist/locales/sw.d.ts +1 -2
- package/dist/locales/sw.js +0 -1
- package/dist/locales/th.d.ts +1 -2
- package/dist/locales/th.js +0 -1
- package/dist/locales/tr.d.ts +1 -2
- package/dist/locales/tr.js +0 -1
- package/dist/locales/types.d.ts +0 -1
- package/dist/locales/vi.d.ts +1 -2
- package/dist/locales/vi.js +0 -1
- package/dist/locales/zh.d.ts +1 -2
- package/dist/locales/zh.js +0 -1
- package/dist/logger.d.ts +0 -1
- package/dist/mini.d.ts +64 -65
- package/dist/mini.js +31 -7
- package/dist/pigment.d.ts +0 -1
- package/dist/pigment.js +6 -4
- package/dist/plugins/index.d.ts +2 -3
- package/dist/plugins/index.js +1 -0
- package/dist/plugins/types.d.ts +4 -5
- package/dist/registry.d.ts +23 -0
- package/dist/registry.js +34 -0
- package/dist/utils/codec-utils.d.ts +0 -1
- package/dist/utils/deep-merge.d.ts +0 -1
- package/dist/utils/ip-validation.d.ts +0 -1
- package/dist/utils/json-schema.d.ts +77 -0
- package/dist/utils/security.d.ts +2 -6
- package/dist/v3/index.d.ts +2 -0
- package/dist/v3/index.js +46 -0
- package/dist/v4/core/index.d.ts +260 -0
- package/dist/v4/core/index.js +277 -0
- package/dist/v4/index.d.ts +4 -0
- package/dist/v4/index.js +50 -0
- package/dist/v4/locales/index.d.ts +53 -0
- package/dist/v4/locales/index.js +77 -0
- package/dist/v4/mini/index.d.ts +2 -0
- package/dist/v4/mini/index.js +47 -0
- package/dist/v4-mini/index.d.ts +22 -0
- package/dist/v4-mini/index.js +75 -0
- package/dist/validators/any.d.ts +7 -2
- package/dist/validators/any.js +37 -0
- package/dist/validators/array.d.ts +9 -2
- package/dist/validators/array.js +279 -0
- package/dist/validators/base.d.ts +228 -5
- package/dist/validators/base.js +868 -0
- package/dist/validators/base64.d.ts +1 -2
- package/dist/validators/base64.js +68 -0
- package/dist/validators/bigint.d.ts +21 -3
- package/dist/validators/bigint.js +228 -0
- package/dist/validators/boolean.d.ts +13 -4
- package/dist/validators/boolean.js +142 -0
- package/dist/validators/codec.d.ts +9 -2
- package/dist/validators/codec.js +200 -0
- package/dist/validators/custom.d.ts +15 -2
- package/dist/validators/custom.js +67 -0
- package/dist/validators/date.d.ts +19 -3
- package/dist/validators/date.js +274 -0
- package/dist/validators/discriminated-union.d.ts +4 -3
- package/dist/validators/discriminated-union.js +123 -0
- package/dist/validators/enum.d.ts +10 -7
- package/dist/validators/enum.js +150 -0
- package/dist/validators/file.d.ts +7 -2
- package/dist/validators/file.js +125 -0
- package/dist/validators/function.d.ts +11 -5
- package/dist/validators/function.js +58 -0
- package/dist/validators/hex.d.ts +1 -2
- package/dist/validators/hex.js +65 -0
- package/dist/validators/index.d.ts +38 -38
- package/dist/validators/index.js +35 -5
- package/dist/validators/intersection.d.ts +1 -2
- package/dist/validators/intersection.js +116 -0
- package/dist/validators/json.d.ts +1 -2
- package/dist/validators/json.js +66 -0
- package/dist/validators/lazy.d.ts +5 -9
- package/dist/validators/lazy.js +50 -0
- package/dist/validators/literal.d.ts +2 -2
- package/dist/validators/literal.js +60 -0
- package/dist/validators/map.d.ts +15 -2
- package/dist/validators/map.js +214 -0
- package/dist/validators/nan.d.ts +2 -3
- package/dist/validators/nan.js +38 -0
- package/dist/validators/never.d.ts +1 -2
- package/dist/validators/never.js +32 -0
- package/dist/validators/null.d.ts +3 -3
- package/dist/validators/null.js +40 -0
- package/dist/validators/number.d.ts +80 -21
- package/dist/validators/number.js +423 -0
- package/dist/validators/object.d.ts +30 -9
- package/dist/validators/object.js +864 -0
- package/dist/validators/promise.d.ts +58 -0
- package/dist/validators/promise.js +111 -0
- package/dist/validators/record.d.ts +11 -2
- package/dist/validators/record.js +258 -0
- package/dist/validators/set.d.ts +11 -2
- package/dist/validators/set.js +199 -0
- package/dist/validators/string-bool.d.ts +7 -10
- package/dist/validators/string-bool.js +120 -0
- package/dist/validators/string-formats.d.ts +13 -4
- package/dist/validators/string-formats.js +135 -0
- package/dist/validators/string.d.ts +39 -18
- package/dist/validators/string.js +4 -0
- package/dist/validators/symbol.d.ts +8 -3
- package/dist/validators/symbol.js +58 -0
- package/dist/validators/template-literal.d.ts +1 -2
- package/dist/validators/template-literal.js +103 -0
- package/dist/validators/tuple.d.ts +15 -2
- package/dist/validators/tuple.js +183 -0
- package/dist/validators/uint8array.d.ts +3 -4
- package/dist/validators/uint8array.js +101 -0
- package/dist/validators/undefined.d.ts +3 -3
- package/dist/validators/undefined.js +40 -0
- package/dist/validators/union.d.ts +7 -4
- package/dist/validators/union.js +187 -0
- package/dist/validators/unknown.d.ts +7 -2
- package/dist/{chunks/unknown-SLIH1VCf.js → validators/unknown.js} +12 -3
- package/dist/validators/void.d.ts +3 -2
- package/dist/validators/void.js +44 -0
- package/dist/validators/xor.d.ts +2 -3
- package/dist/validators/xor.js +66 -0
- package/package.json +116 -31
- package/dist/chunks/bigint-DgsCr2dC.js +0 -1709
- package/dist/chunks/bigint-DgsCr2dC.js.map +0 -1
- package/dist/chunks/date-ODue_rtq.js.map +0 -1
- package/dist/chunks/index-BZqWZvVe.js +0 -426
- package/dist/chunks/index-BZqWZvVe.js.map +0 -1
- package/dist/chunks/index-CETyGkrv.js.map +0 -1
- package/dist/chunks/json-o20GFhTh.js +0 -2021
- package/dist/chunks/json-o20GFhTh.js.map +0 -1
- package/dist/chunks/unknown-SLIH1VCf.js.map +0 -1
- package/dist/cjs/errors.cjs.map +0 -1
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/locales/index.cjs.map +0 -1
- package/dist/cjs/locales/lazy.cjs.map +0 -1
- package/dist/cjs/mini.cjs.map +0 -1
- package/dist/cli/bin.d.ts.map +0 -1
- package/dist/cli/commands/benchmark.d.ts.map +0 -1
- package/dist/cli/commands/validate.d.ts.map +0 -1
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/codecs/index.d.ts.map +0 -1
- package/dist/codecs/index.js.map +0 -1
- package/dist/coercion/bigint.d.ts.map +0 -1
- package/dist/coercion/boolean.d.ts.map +0 -1
- package/dist/coercion/date.d.ts.map +0 -1
- package/dist/coercion/index.d.ts.map +0 -1
- package/dist/coercion/index.js.map +0 -1
- package/dist/coercion/number.d.ts.map +0 -1
- package/dist/coercion/string.d.ts.map +0 -1
- package/dist/compat/emitter.d.ts.map +0 -1
- package/dist/compat/emitter.js.map +0 -1
- package/dist/compat/index.d.ts.map +0 -1
- package/dist/compat/result.d.ts.map +0 -1
- package/dist/compat/result.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/events.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/kernel.d.ts.map +0 -1
- package/dist/kernel.js.map +0 -1
- package/dist/locales/af.d.ts.map +0 -1
- package/dist/locales/af.js.map +0 -1
- package/dist/locales/ar.d.ts.map +0 -1
- package/dist/locales/ar.js.map +0 -1
- package/dist/locales/backup-en.d.ts +0 -3
- package/dist/locales/backup-en.d.ts.map +0 -1
- package/dist/locales/bn.d.ts.map +0 -1
- package/dist/locales/bn.js.map +0 -1
- package/dist/locales/da.d.ts.map +0 -1
- package/dist/locales/da.js.map +0 -1
- package/dist/locales/de.d.ts.map +0 -1
- package/dist/locales/de.js.map +0 -1
- package/dist/locales/en.d.ts.map +0 -1
- package/dist/locales/en.js.map +0 -1
- package/dist/locales/es-MX.d.ts.map +0 -1
- package/dist/locales/es-MX.js.map +0 -1
- package/dist/locales/es.d.ts.map +0 -1
- package/dist/locales/es.js.map +0 -1
- package/dist/locales/fi.d.ts.map +0 -1
- package/dist/locales/fi.js.map +0 -1
- package/dist/locales/fr.d.ts.map +0 -1
- package/dist/locales/fr.js.map +0 -1
- package/dist/locales/hi.d.ts.map +0 -1
- package/dist/locales/hi.js.map +0 -1
- package/dist/locales/id.d.ts.map +0 -1
- package/dist/locales/id.js.map +0 -1
- package/dist/locales/index.d.ts.map +0 -1
- package/dist/locales/index.js.map +0 -1
- package/dist/locales/it.d.ts.map +0 -1
- package/dist/locales/it.js.map +0 -1
- package/dist/locales/ja.d.ts.map +0 -1
- package/dist/locales/ja.js.map +0 -1
- package/dist/locales/ko.d.ts.map +0 -1
- package/dist/locales/ko.js.map +0 -1
- package/dist/locales/lazy.d.ts.map +0 -1
- package/dist/locales/lazy.js.map +0 -1
- package/dist/locales/nl.d.ts.map +0 -1
- package/dist/locales/nl.js.map +0 -1
- package/dist/locales/no.d.ts.map +0 -1
- package/dist/locales/no.js.map +0 -1
- package/dist/locales/pl.d.ts.map +0 -1
- package/dist/locales/pl.js.map +0 -1
- package/dist/locales/pt-BR.d.ts.map +0 -1
- package/dist/locales/pt-BR.js.map +0 -1
- package/dist/locales/pt.d.ts.map +0 -1
- package/dist/locales/pt.js.map +0 -1
- package/dist/locales/ru.d.ts.map +0 -1
- package/dist/locales/ru.js.map +0 -1
- package/dist/locales/sv.d.ts.map +0 -1
- package/dist/locales/sv.js.map +0 -1
- package/dist/locales/sw.d.ts.map +0 -1
- package/dist/locales/sw.js.map +0 -1
- package/dist/locales/th.d.ts.map +0 -1
- package/dist/locales/th.js.map +0 -1
- package/dist/locales/tr.d.ts.map +0 -1
- package/dist/locales/tr.js.map +0 -1
- package/dist/locales/types.d.ts.map +0 -1
- package/dist/locales/vi.d.ts.map +0 -1
- package/dist/locales/vi.js.map +0 -1
- package/dist/locales/zh.d.ts.map +0 -1
- package/dist/locales/zh.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/mini.d.ts.map +0 -1
- package/dist/mini.js.map +0 -1
- package/dist/pigment.d.ts.map +0 -1
- package/dist/pigment.js.map +0 -1
- package/dist/plugins/index.d.ts.map +0 -1
- package/dist/plugins/types.d.ts.map +0 -1
- package/dist/utils/codec-utils.d.ts.map +0 -1
- package/dist/utils/deep-merge.d.ts.map +0 -1
- package/dist/utils/ip-validation.d.ts.map +0 -1
- package/dist/utils/security.d.ts.map +0 -1
- package/dist/validators/any.d.ts.map +0 -1
- package/dist/validators/array.d.ts.map +0 -1
- package/dist/validators/base.d.ts.map +0 -1
- package/dist/validators/base64.d.ts.map +0 -1
- package/dist/validators/bigint.d.ts.map +0 -1
- package/dist/validators/boolean.d.ts.map +0 -1
- package/dist/validators/codec.d.ts.map +0 -1
- package/dist/validators/custom.d.ts.map +0 -1
- package/dist/validators/date.d.ts.map +0 -1
- package/dist/validators/discriminated-union.d.ts.map +0 -1
- package/dist/validators/enum.d.ts.map +0 -1
- package/dist/validators/file.d.ts.map +0 -1
- package/dist/validators/function.d.ts.map +0 -1
- package/dist/validators/hex.d.ts.map +0 -1
- package/dist/validators/index.d.ts.map +0 -1
- package/dist/validators/index.js.map +0 -1
- package/dist/validators/intersection.d.ts.map +0 -1
- package/dist/validators/json.d.ts.map +0 -1
- package/dist/validators/lazy.d.ts.map +0 -1
- package/dist/validators/literal.d.ts.map +0 -1
- package/dist/validators/map.d.ts.map +0 -1
- package/dist/validators/nan.d.ts.map +0 -1
- package/dist/validators/never.d.ts.map +0 -1
- package/dist/validators/null.d.ts.map +0 -1
- package/dist/validators/number.d.ts.map +0 -1
- package/dist/validators/object.d.ts.map +0 -1
- package/dist/validators/record.d.ts.map +0 -1
- package/dist/validators/set.d.ts.map +0 -1
- package/dist/validators/string-bool.d.ts.map +0 -1
- package/dist/validators/string-formats.d.ts.map +0 -1
- package/dist/validators/string.d.ts.map +0 -1
- package/dist/validators/symbol.d.ts.map +0 -1
- package/dist/validators/template-literal.d.ts.map +0 -1
- package/dist/validators/tuple.d.ts.map +0 -1
- package/dist/validators/uint8array.d.ts.map +0 -1
- package/dist/validators/undefined.d.ts.map +0 -1
- package/dist/validators/union.d.ts.map +0 -1
- package/dist/validators/unknown.d.ts.map +0 -1
- package/dist/validators/void.d.ts.map +0 -1
- package/dist/validators/xor.d.ts.map +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Event Emitter Implementation
|
|
5
|
+
*
|
|
6
|
+
* This module provides a type-safe event emitter,
|
|
7
|
+
* compatible with @oxog/emitter when available.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a type-safe event emitter
|
|
11
|
+
*/
|
|
12
|
+
function createEmitter() {
|
|
13
|
+
const listeners = new Map();
|
|
14
|
+
const getListeners = (event) => {
|
|
15
|
+
if (!listeners.has(event)) {
|
|
16
|
+
listeners.set(event, []);
|
|
17
|
+
}
|
|
18
|
+
return listeners.get(event);
|
|
19
|
+
};
|
|
20
|
+
const sortListeners = (event) => {
|
|
21
|
+
const eventListeners = getListeners(event);
|
|
22
|
+
eventListeners.sort((a, b) => b.priority - a.priority);
|
|
23
|
+
};
|
|
24
|
+
const on = (event, handler, options = {}) => {
|
|
25
|
+
const entry = {
|
|
26
|
+
handler,
|
|
27
|
+
once: options.once ?? false,
|
|
28
|
+
priority: options.priority ?? 0
|
|
29
|
+
};
|
|
30
|
+
getListeners(event).push(entry);
|
|
31
|
+
sortListeners(event);
|
|
32
|
+
// Return unsubscribe function
|
|
33
|
+
return () => off(event, handler);
|
|
34
|
+
};
|
|
35
|
+
const once = (event, handler) => {
|
|
36
|
+
return on(event, handler, { once: true });
|
|
37
|
+
};
|
|
38
|
+
const off = (event, handler) => {
|
|
39
|
+
const eventListeners = listeners.get(event);
|
|
40
|
+
if (!eventListeners)
|
|
41
|
+
return;
|
|
42
|
+
const index = eventListeners.findIndex((entry) => entry.handler === handler);
|
|
43
|
+
if (index !== -1) {
|
|
44
|
+
eventListeners.splice(index, 1);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const emit = (event, payload) => {
|
|
48
|
+
const eventListeners = listeners.get(event);
|
|
49
|
+
if (!eventListeners || eventListeners.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
// Create a copy to allow modifications during iteration
|
|
52
|
+
const listenersToCall = [...eventListeners];
|
|
53
|
+
for (const entry of listenersToCall) {
|
|
54
|
+
if (entry.once) {
|
|
55
|
+
off(event, entry.handler);
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
entry.handler(payload);
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
// Log error but don't stop other handlers
|
|
62
|
+
console.error(`Error in event handler for "${String(event)}":`, error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const emitAsync = async (event, payload) => {
|
|
67
|
+
const eventListeners = listeners.get(event);
|
|
68
|
+
if (!eventListeners || eventListeners.length === 0)
|
|
69
|
+
return;
|
|
70
|
+
// Create a copy to allow modifications during iteration
|
|
71
|
+
const listenersToCall = [...eventListeners];
|
|
72
|
+
for (const entry of listenersToCall) {
|
|
73
|
+
if (entry.once) {
|
|
74
|
+
off(event, entry.handler);
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
await entry.handler(payload);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
// Log error but don't stop other handlers
|
|
81
|
+
console.error(`Error in async event handler for "${String(event)}":`, error);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const removeAllListeners = (event) => {
|
|
86
|
+
if (event !== undefined) {
|
|
87
|
+
listeners.delete(event);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
listeners.clear();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const listenerCount = (event) => {
|
|
94
|
+
return listeners.get(event)?.length ?? 0;
|
|
95
|
+
};
|
|
96
|
+
const eventNames = () => {
|
|
97
|
+
return Array.from(listeners.keys()).filter((key) => {
|
|
98
|
+
const eventListeners = listeners.get(key);
|
|
99
|
+
return eventListeners !== undefined && eventListeners.length > 0;
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
on,
|
|
104
|
+
once,
|
|
105
|
+
off,
|
|
106
|
+
emit,
|
|
107
|
+
emitAsync,
|
|
108
|
+
removeAllListeners,
|
|
109
|
+
listenerCount,
|
|
110
|
+
eventNames
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Mixin to add event emitter capabilities to a class
|
|
115
|
+
*/
|
|
116
|
+
function withEmitter() {
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
return function (Base) {
|
|
119
|
+
return class extends Base {
|
|
120
|
+
constructor() {
|
|
121
|
+
super(...arguments);
|
|
122
|
+
/** @internal */
|
|
123
|
+
this._emitter = createEmitter();
|
|
124
|
+
}
|
|
125
|
+
on(event, handler, options) {
|
|
126
|
+
return this._emitter.on(event, handler, options);
|
|
127
|
+
}
|
|
128
|
+
once(event, handler) {
|
|
129
|
+
return this._emitter.once(event, handler);
|
|
130
|
+
}
|
|
131
|
+
off(event, handler) {
|
|
132
|
+
this._emitter.off(event, handler);
|
|
133
|
+
}
|
|
134
|
+
emit(event, payload) {
|
|
135
|
+
this._emitter.emit(event, payload);
|
|
136
|
+
}
|
|
137
|
+
async emitAsync(event, payload) {
|
|
138
|
+
await this._emitter.emitAsync(event, payload);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Create an event bus for global event handling
|
|
145
|
+
*/
|
|
146
|
+
function createEventBus() {
|
|
147
|
+
const emitter = createEmitter();
|
|
148
|
+
const createScope = () => {
|
|
149
|
+
const unsubscribers = [];
|
|
150
|
+
const scopedEmitter = {
|
|
151
|
+
on: (event, handler, options) => {
|
|
152
|
+
const unsubscribe = emitter.on(event, handler, options);
|
|
153
|
+
unsubscribers.push(unsubscribe);
|
|
154
|
+
return unsubscribe;
|
|
155
|
+
},
|
|
156
|
+
once: (event, handler) => {
|
|
157
|
+
const unsubscribe = emitter.once(event, handler);
|
|
158
|
+
unsubscribers.push(unsubscribe);
|
|
159
|
+
return unsubscribe;
|
|
160
|
+
},
|
|
161
|
+
off: emitter.off,
|
|
162
|
+
emit: emitter.emit,
|
|
163
|
+
emitAsync: emitter.emitAsync,
|
|
164
|
+
removeAllListeners: emitter.removeAllListeners,
|
|
165
|
+
listenerCount: emitter.listenerCount,
|
|
166
|
+
eventNames: emitter.eventNames,
|
|
167
|
+
dispose: () => {
|
|
168
|
+
for (const unsubscribe of unsubscribers) {
|
|
169
|
+
unsubscribe();
|
|
170
|
+
}
|
|
171
|
+
unsubscribers.length = 0;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
return scopedEmitter;
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
...emitter,
|
|
178
|
+
createScope
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
exports.createEmitter = createEmitter;
|
|
183
|
+
exports.createEventBus = createEventBus;
|
|
184
|
+
exports.withEmitter = withEmitter;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Result Pattern Implementation
|
|
5
|
+
*
|
|
6
|
+
* This module provides a Result type for functional error handling,
|
|
7
|
+
* compatible with @oxog/types when available.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a success result
|
|
11
|
+
*/
|
|
12
|
+
function Ok(data) {
|
|
13
|
+
return { success: true, data, value: data };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create an error result
|
|
17
|
+
*/
|
|
18
|
+
function Err(error) {
|
|
19
|
+
return { success: false, error };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a success result (alias)
|
|
23
|
+
*/
|
|
24
|
+
const success = Ok;
|
|
25
|
+
/**
|
|
26
|
+
* Create a failure result (alias)
|
|
27
|
+
*/
|
|
28
|
+
const failure = Err;
|
|
29
|
+
/**
|
|
30
|
+
* Check if result is Ok
|
|
31
|
+
*/
|
|
32
|
+
function isOk(result) {
|
|
33
|
+
return result.success === true;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if result is Err
|
|
37
|
+
*/
|
|
38
|
+
function isErr(result) {
|
|
39
|
+
return result.success === false;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Check if value is a Result
|
|
43
|
+
*/
|
|
44
|
+
function isResult(value) {
|
|
45
|
+
return (typeof value === 'object' &&
|
|
46
|
+
value !== null &&
|
|
47
|
+
'success' in value &&
|
|
48
|
+
typeof value.success === 'boolean');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Unwrap a result, throwing the error if it's an Err
|
|
52
|
+
*/
|
|
53
|
+
function unwrap(result) {
|
|
54
|
+
if (isOk(result)) {
|
|
55
|
+
return result.data;
|
|
56
|
+
}
|
|
57
|
+
throw result.error;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Unwrap a result with a default value
|
|
61
|
+
*/
|
|
62
|
+
function unwrapOr(result, defaultValue) {
|
|
63
|
+
if (isOk(result)) {
|
|
64
|
+
return result.data;
|
|
65
|
+
}
|
|
66
|
+
return defaultValue;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Map over a successful result
|
|
70
|
+
*/
|
|
71
|
+
function map(result, fn) {
|
|
72
|
+
if (isOk(result)) {
|
|
73
|
+
return Ok(fn(result.data));
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Map over an error result
|
|
79
|
+
*/
|
|
80
|
+
function mapErr(result, fn) {
|
|
81
|
+
if (isErr(result)) {
|
|
82
|
+
return Err(fn(result.error));
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Chain results (flatMap)
|
|
88
|
+
*/
|
|
89
|
+
function flatMap(result, fn) {
|
|
90
|
+
if (isOk(result)) {
|
|
91
|
+
return fn(result.data);
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Pattern match on a result
|
|
97
|
+
*/
|
|
98
|
+
function match(result, handlers) {
|
|
99
|
+
if (isOk(result)) {
|
|
100
|
+
return handlers.ok(result.data);
|
|
101
|
+
}
|
|
102
|
+
return handlers.err(result.error);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Try to execute a function and wrap the result
|
|
106
|
+
*/
|
|
107
|
+
function tryCatch(fn) {
|
|
108
|
+
try {
|
|
109
|
+
return Ok(fn());
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
return Err(error instanceof Error ? error : new Error(String(error)));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Try to execute an async function and wrap the result
|
|
117
|
+
*/
|
|
118
|
+
async function tryCatchAsync(fn) {
|
|
119
|
+
try {
|
|
120
|
+
return Ok(await fn());
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
return Err(error instanceof Error ? error : new Error(String(error)));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Combine multiple results into a single result
|
|
128
|
+
* Returns Ok with array of values if all succeed, Err with first error otherwise
|
|
129
|
+
*/
|
|
130
|
+
function all(results) {
|
|
131
|
+
const values = [];
|
|
132
|
+
for (const result of results) {
|
|
133
|
+
if (isErr(result)) {
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
values.push(result.data);
|
|
137
|
+
}
|
|
138
|
+
return Ok(values);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Convert a nullable value to a Result
|
|
142
|
+
*/
|
|
143
|
+
function fromNullable(value, error = new Error('Value is null or undefined')) {
|
|
144
|
+
if (value === null || value === undefined) {
|
|
145
|
+
return Err(error);
|
|
146
|
+
}
|
|
147
|
+
return Ok(value);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Result utilities namespace
|
|
151
|
+
*/
|
|
152
|
+
const ResultUtils = {
|
|
153
|
+
Ok,
|
|
154
|
+
Err,
|
|
155
|
+
success,
|
|
156
|
+
failure,
|
|
157
|
+
isOk,
|
|
158
|
+
isErr,
|
|
159
|
+
isResult,
|
|
160
|
+
unwrap,
|
|
161
|
+
unwrapOr,
|
|
162
|
+
map,
|
|
163
|
+
mapErr,
|
|
164
|
+
flatMap,
|
|
165
|
+
match,
|
|
166
|
+
tryCatch,
|
|
167
|
+
tryCatchAsync,
|
|
168
|
+
all,
|
|
169
|
+
fromNullable
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
exports.Err = Err;
|
|
173
|
+
exports.Ok = Ok;
|
|
174
|
+
exports.ResultUtils = ResultUtils;
|
|
175
|
+
exports.all = all;
|
|
176
|
+
exports.failure = failure;
|
|
177
|
+
exports.flatMap = flatMap;
|
|
178
|
+
exports.fromNullable = fromNullable;
|
|
179
|
+
exports.isErr = isErr;
|
|
180
|
+
exports.isOk = isOk;
|
|
181
|
+
exports.isResult = isResult;
|
|
182
|
+
exports.map = map;
|
|
183
|
+
exports.mapErr = mapErr;
|
|
184
|
+
exports.match = match;
|
|
185
|
+
exports.success = success;
|
|
186
|
+
exports.tryCatch = tryCatch;
|
|
187
|
+
exports.tryCatchAsync = tryCatchAsync;
|
|
188
|
+
exports.unwrap = unwrap;
|
|
189
|
+
exports.unwrapOr = unwrapOr;
|
package/dist/cjs/errors.cjs
CHANGED
|
@@ -1,216 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* This module provides ANSI color utilities for terminal output,
|
|
7
|
-
* compatible with @oxog/pigment when available.
|
|
8
|
-
*/
|
|
9
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
10
|
-
/**
|
|
11
|
-
* Check if colors are supported in the current environment
|
|
12
|
-
*/
|
|
13
|
-
function supportsColor() {
|
|
14
|
-
// Check for NO_COLOR environment variable
|
|
15
|
-
if (typeof process !== 'undefined' && process.env?.NO_COLOR) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
// Check for FORCE_COLOR environment variable
|
|
19
|
-
if (typeof process !== 'undefined' && process.env?.FORCE_COLOR) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
// Check for TTY
|
|
23
|
-
if (typeof process !== 'undefined' && process.stdout?.isTTY) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
// Browser environment - no ANSI colors
|
|
27
|
-
if (typeof window !== 'undefined') {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
return false;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* ANSI escape codes
|
|
34
|
-
*/
|
|
35
|
-
const ANSI = {
|
|
36
|
-
// Reset
|
|
37
|
-
reset: '\x1b[0m',
|
|
38
|
-
// Styles
|
|
39
|
-
bold: '\x1b[1m',
|
|
40
|
-
dim: '\x1b[2m',
|
|
41
|
-
italic: '\x1b[3m',
|
|
42
|
-
underline: '\x1b[4m',
|
|
43
|
-
inverse: '\x1b[7m',
|
|
44
|
-
hidden: '\x1b[8m',
|
|
45
|
-
strikethrough: '\x1b[9m',
|
|
46
|
-
// Foreground colors
|
|
47
|
-
black: '\x1b[30m',
|
|
48
|
-
red: '\x1b[31m',
|
|
49
|
-
green: '\x1b[32m',
|
|
50
|
-
yellow: '\x1b[33m',
|
|
51
|
-
blue: '\x1b[34m',
|
|
52
|
-
magenta: '\x1b[35m',
|
|
53
|
-
cyan: '\x1b[36m',
|
|
54
|
-
white: '\x1b[37m',
|
|
55
|
-
gray: '\x1b[90m',
|
|
56
|
-
grey: '\x1b[90m',
|
|
57
|
-
// Bright foreground colors
|
|
58
|
-
brightRed: '\x1b[91m',
|
|
59
|
-
brightGreen: '\x1b[92m',
|
|
60
|
-
brightYellow: '\x1b[93m',
|
|
61
|
-
brightBlue: '\x1b[94m',
|
|
62
|
-
brightMagenta: '\x1b[95m',
|
|
63
|
-
brightCyan: '\x1b[96m',
|
|
64
|
-
brightWhite: '\x1b[97m',
|
|
65
|
-
// Background colors
|
|
66
|
-
bgBlack: '\x1b[40m',
|
|
67
|
-
bgRed: '\x1b[41m',
|
|
68
|
-
bgGreen: '\x1b[42m',
|
|
69
|
-
bgYellow: '\x1b[43m',
|
|
70
|
-
bgBlue: '\x1b[44m',
|
|
71
|
-
bgMagenta: '\x1b[45m',
|
|
72
|
-
bgCyan: '\x1b[46m',
|
|
73
|
-
bgWhite: '\x1b[47m'};
|
|
74
|
-
/**
|
|
75
|
-
* Create a color function
|
|
76
|
-
*/
|
|
77
|
-
function createColorFn(code) {
|
|
78
|
-
const enabled = supportsColor();
|
|
79
|
-
return (text) => {
|
|
80
|
-
if (!enabled || text === '')
|
|
81
|
-
return text;
|
|
82
|
-
return `${code}${text}${ANSI.reset}`;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Pigment - Color utilities for terminal output
|
|
87
|
-
*/
|
|
88
|
-
const pigment = {
|
|
89
|
-
// Styles
|
|
90
|
-
bold: createColorFn(ANSI.bold),
|
|
91
|
-
dim: createColorFn(ANSI.dim),
|
|
92
|
-
italic: createColorFn(ANSI.italic),
|
|
93
|
-
underline: createColorFn(ANSI.underline),
|
|
94
|
-
inverse: createColorFn(ANSI.inverse),
|
|
95
|
-
hidden: createColorFn(ANSI.hidden),
|
|
96
|
-
strikethrough: createColorFn(ANSI.strikethrough),
|
|
97
|
-
// Foreground colors
|
|
98
|
-
black: createColorFn(ANSI.black),
|
|
99
|
-
red: createColorFn(ANSI.red),
|
|
100
|
-
green: createColorFn(ANSI.green),
|
|
101
|
-
yellow: createColorFn(ANSI.yellow),
|
|
102
|
-
blue: createColorFn(ANSI.blue),
|
|
103
|
-
magenta: createColorFn(ANSI.magenta),
|
|
104
|
-
cyan: createColorFn(ANSI.cyan),
|
|
105
|
-
white: createColorFn(ANSI.white),
|
|
106
|
-
gray: createColorFn(ANSI.gray),
|
|
107
|
-
grey: createColorFn(ANSI.grey),
|
|
108
|
-
// Bright colors
|
|
109
|
-
brightRed: createColorFn(ANSI.brightRed),
|
|
110
|
-
brightGreen: createColorFn(ANSI.brightGreen),
|
|
111
|
-
brightYellow: createColorFn(ANSI.brightYellow),
|
|
112
|
-
brightBlue: createColorFn(ANSI.brightBlue),
|
|
113
|
-
brightMagenta: createColorFn(ANSI.brightMagenta),
|
|
114
|
-
brightCyan: createColorFn(ANSI.brightCyan),
|
|
115
|
-
brightWhite: createColorFn(ANSI.brightWhite),
|
|
116
|
-
// Background colors
|
|
117
|
-
bgBlack: createColorFn(ANSI.bgBlack),
|
|
118
|
-
bgRed: createColorFn(ANSI.bgRed),
|
|
119
|
-
bgGreen: createColorFn(ANSI.bgGreen),
|
|
120
|
-
bgYellow: createColorFn(ANSI.bgYellow),
|
|
121
|
-
bgBlue: createColorFn(ANSI.bgBlue),
|
|
122
|
-
bgMagenta: createColorFn(ANSI.bgMagenta),
|
|
123
|
-
bgCyan: createColorFn(ANSI.bgCyan),
|
|
124
|
-
bgWhite: createColorFn(ANSI.bgWhite),
|
|
125
|
-
// Semantic colors
|
|
126
|
-
success: createColorFn(ANSI.green),
|
|
127
|
-
error: createColorFn(ANSI.red),
|
|
128
|
-
warning: createColorFn(ANSI.yellow),
|
|
129
|
-
info: createColorFn(ANSI.blue),
|
|
130
|
-
muted: createColorFn(ANSI.gray)};
|
|
131
|
-
// Aliases for convenience
|
|
132
|
-
const { bold, dim, red, green, yellow, blue, cyan} = pigment;
|
|
133
|
-
/**
|
|
134
|
-
* Default VLD theme for error formatting
|
|
135
|
-
*/
|
|
136
|
-
const vldTheme = {
|
|
137
|
-
error: red,
|
|
138
|
-
success: green,
|
|
139
|
-
warning: yellow,
|
|
140
|
-
info: blue,
|
|
141
|
-
muted: dim,
|
|
142
|
-
path: cyan,
|
|
143
|
-
value: yellow,
|
|
144
|
-
key: bold,
|
|
145
|
-
symbol: red
|
|
146
|
-
};
|
|
3
|
+
var pigment = require('./pigment.cjs');
|
|
4
|
+
var errorsCore = require('./chunks/errors-core-DWxLFs2f.cjs');
|
|
147
5
|
|
|
148
6
|
// VLD Error System - Advanced error formatting and utilities
|
|
149
|
-
class VldError extends Error {
|
|
150
|
-
constructor(issues) {
|
|
151
|
-
const message = issues.length === 1 ? issues[0].message : `${issues.length} validation errors`;
|
|
152
|
-
super(message);
|
|
153
|
-
this.name = 'VldError';
|
|
154
|
-
this.issues = issues;
|
|
155
|
-
// Maintain proper stack trace
|
|
156
|
-
if (Error.captureStackTrace) {
|
|
157
|
-
Error.captureStackTrace(this, VldError);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
get firstError() {
|
|
161
|
-
return this.issues[0];
|
|
162
|
-
}
|
|
163
|
-
get formattedErrors() {
|
|
164
|
-
return this.issues.map((issue) => issue.message);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Convert error to JSON representation
|
|
168
|
-
* Compatible with @oxog/types OxogError
|
|
169
|
-
*/
|
|
170
|
-
toJSON() {
|
|
171
|
-
return {
|
|
172
|
-
name: this.name,
|
|
173
|
-
message: this.message,
|
|
174
|
-
code: 'VLD_VALIDATION_ERROR',
|
|
175
|
-
issues: this.issues.map((issue) => ({
|
|
176
|
-
code: issue.code,
|
|
177
|
-
path: issue.path,
|
|
178
|
-
message: issue.message,
|
|
179
|
-
expected: issue.expected,
|
|
180
|
-
received: issue.received,
|
|
181
|
-
keys: issue.keys,
|
|
182
|
-
minimum: issue.minimum,
|
|
183
|
-
maximum: issue.maximum,
|
|
184
|
-
exact: issue.exact,
|
|
185
|
-
inclusive: issue.inclusive
|
|
186
|
-
}))
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Create VldError from JSON representation
|
|
191
|
-
*/
|
|
192
|
-
static fromJSON(json) {
|
|
193
|
-
const issues = json.issues.map((issue) => ({
|
|
194
|
-
code: issue.code,
|
|
195
|
-
path: issue.path,
|
|
196
|
-
message: issue.message,
|
|
197
|
-
expected: issue.expected,
|
|
198
|
-
received: issue.received,
|
|
199
|
-
keys: issue.keys,
|
|
200
|
-
minimum: issue.minimum,
|
|
201
|
-
maximum: issue.maximum,
|
|
202
|
-
exact: issue.exact,
|
|
203
|
-
inclusive: issue.inclusive
|
|
204
|
-
}));
|
|
205
|
-
return new VldError(issues);
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Check if a value is a VldError
|
|
209
|
-
*/
|
|
210
|
-
static isVldError(value) {
|
|
211
|
-
return value instanceof VldError;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
7
|
/**
|
|
215
8
|
* Convert VldError to a nested tree structure
|
|
216
9
|
*/
|
|
@@ -268,7 +61,7 @@ function treeifyError(error) {
|
|
|
268
61
|
* Convert VldError to human-readable string
|
|
269
62
|
*/
|
|
270
63
|
function prettifyError(error, options = {}) {
|
|
271
|
-
const { colored = true, theme = vldTheme, includeCode = false, includeDetails = false } = options;
|
|
64
|
+
const { colored = true, theme = pigment.vldTheme, includeCode = false, includeDetails = false } = options;
|
|
272
65
|
const lines = [];
|
|
273
66
|
for (const issue of error.issues) {
|
|
274
67
|
// Symbol and message
|
|
@@ -341,7 +134,8 @@ function flattenError(error) {
|
|
|
341
134
|
formErrors.push(issue.message);
|
|
342
135
|
}
|
|
343
136
|
else {
|
|
344
|
-
const
|
|
137
|
+
const firstPathSegment = issue.path[0];
|
|
138
|
+
const fieldName = firstPathSegment.toString();
|
|
345
139
|
if (!fieldErrors[fieldName]) {
|
|
346
140
|
fieldErrors[fieldName] = [];
|
|
347
141
|
}
|
|
@@ -376,7 +170,7 @@ function getValueType(value) {
|
|
|
376
170
|
return typeof value;
|
|
377
171
|
}
|
|
378
172
|
|
|
379
|
-
exports.VldError = VldError;
|
|
173
|
+
exports.VldError = errorsCore.VldError;
|
|
380
174
|
exports.createIssue = createIssue;
|
|
381
175
|
exports.flattenError = flattenError;
|
|
382
176
|
exports.getValueType = getValueType;
|
|
@@ -384,4 +178,3 @@ exports.prettifyError = prettifyError;
|
|
|
384
178
|
exports.prettifyErrorColored = prettifyErrorColored;
|
|
385
179
|
exports.prettifyErrorPlain = prettifyErrorPlain;
|
|
386
180
|
exports.treeifyError = treeifyError;
|
|
387
|
-
//# sourceMappingURL=errors.cjs.map
|