@oxog/vld 3.0.1 → 3.0.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 +985 -781
- package/README.md +28 -11
- package/dist/chunks/index-Bn85LHAC.js +1 -0
- package/dist/cjs/chunks/index-DJwZFerZ.cjs +1 -0
- package/dist/cjs/cli/bin.cjs +1 -1
- package/dist/cjs/compile.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/locales/af.cjs +1 -1
- package/dist/cjs/locales/ar.cjs +1 -1
- package/dist/cjs/locales/bn.cjs +1 -1
- package/dist/cjs/locales/da.cjs +1 -1
- package/dist/cjs/locales/de.cjs +1 -1
- package/dist/cjs/locales/en.cjs +1 -1
- package/dist/cjs/locales/es-MX.cjs +1 -1
- package/dist/cjs/locales/es.cjs +1 -1
- package/dist/cjs/locales/fi.cjs +1 -1
- package/dist/cjs/locales/fr.cjs +1 -1
- package/dist/cjs/locales/gu.cjs +1 -1
- package/dist/cjs/locales/hi.cjs +1 -1
- package/dist/cjs/locales/id.cjs +1 -1
- package/dist/cjs/locales/index.cjs +1 -1
- package/dist/cjs/locales/it.cjs +1 -1
- package/dist/cjs/locales/ja.cjs +1 -1
- package/dist/cjs/locales/kn.cjs +1 -1
- package/dist/cjs/locales/ko.cjs +1 -1
- package/dist/cjs/locales/ne.cjs +1 -1
- package/dist/cjs/locales/nl.cjs +1 -1
- package/dist/cjs/locales/no.cjs +1 -1
- package/dist/cjs/locales/pl.cjs +1 -1
- package/dist/cjs/locales/pt-BR-v4.cjs +1 -1
- package/dist/cjs/locales/pt-BR.cjs +1 -1
- package/dist/cjs/locales/pt.cjs +1 -1
- package/dist/cjs/locales/ru.cjs +1 -1
- package/dist/cjs/locales/sk.cjs +1 -1
- package/dist/cjs/locales/sv.cjs +1 -1
- package/dist/cjs/locales/sw.cjs +1 -1
- package/dist/cjs/locales/tg.cjs +1 -0
- package/dist/cjs/locales/th.cjs +1 -1
- package/dist/cjs/locales/tr.cjs +1 -1
- package/dist/cjs/locales/vi.cjs +1 -1
- package/dist/cjs/locales/zh.cjs +1 -1
- package/dist/cjs/v3/index.cjs +1 -1
- package/dist/cjs/v4/core/index.cjs +1 -1
- package/dist/cjs/v4/index.cjs +1 -1
- package/dist/cjs/v4/locales/index.cjs +1 -1
- package/dist/cjs/v4/mini/index.cjs +1 -1
- package/dist/cjs/v4-mini/index.cjs +1 -1
- package/dist/cjs/validators/base.cjs +1 -1
- package/dist/cjs/validators/custom.cjs +1 -1
- package/dist/cjs/validators/number-v2.cjs +1 -1
- package/dist/cjs/validators/object.cjs +1 -1
- package/dist/cjs/validators/promise.cjs +1 -1
- package/dist/cjs/validators/string-formats.cjs +1 -1
- package/dist/cjs/validators/string.cjs +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/compile.d.ts +15 -0
- package/dist/compile.js +1 -1
- package/dist/index.d.ts +50 -17
- package/dist/index.js +1 -1
- package/dist/locales/af.js +1 -1
- package/dist/locales/ar.js +1 -1
- package/dist/locales/bn.js +1 -1
- package/dist/locales/da.js +1 -1
- package/dist/locales/de.js +1 -1
- package/dist/locales/en.js +1 -1
- package/dist/locales/es-MX.js +1 -1
- package/dist/locales/es.js +1 -1
- package/dist/locales/fi.js +1 -1
- package/dist/locales/fr.js +1 -1
- package/dist/locales/gu.js +1 -1
- package/dist/locales/hi.js +1 -1
- package/dist/locales/id.js +1 -1
- package/dist/locales/index.js +1 -1
- package/dist/locales/it.js +1 -1
- package/dist/locales/ja.js +1 -1
- package/dist/locales/kn.js +1 -1
- package/dist/locales/ko.js +1 -1
- package/dist/locales/ne.js +1 -1
- package/dist/locales/nl.js +1 -1
- package/dist/locales/no.js +1 -1
- package/dist/locales/pl.js +1 -1
- package/dist/locales/pt-BR-v4.js +1 -1
- package/dist/locales/pt-BR.js +1 -1
- package/dist/locales/pt.js +1 -1
- package/dist/locales/ru.js +1 -1
- package/dist/locales/sk.js +1 -1
- package/dist/locales/sv.js +1 -1
- package/dist/locales/sw.js +1 -1
- package/dist/locales/tg.d.ts +2 -0
- package/dist/locales/tg.js +1 -0
- package/dist/locales/th.js +1 -1
- package/dist/locales/tr.js +1 -1
- package/dist/locales/types.d.ts +1 -0
- package/dist/locales/vi.js +1 -1
- package/dist/locales/zh.js +1 -1
- package/dist/utils/json-schema.d.ts +4 -0
- package/dist/v3/index.js +1 -1
- package/dist/v4/core/index.d.ts +12 -2
- package/dist/v4/core/index.js +1 -1
- package/dist/v4/index.js +1 -1
- package/dist/v4/locales/index.d.ts +1 -0
- package/dist/v4/locales/index.js +1 -1
- package/dist/v4/mini/index.js +1 -1
- package/dist/v4-mini/index.d.ts +1 -1
- package/dist/v4-mini/index.js +1 -1
- package/dist/validators/array-v2.d.ts +1 -1
- package/dist/validators/base.d.ts +29 -0
- package/dist/validators/base.js +1 -1
- package/dist/validators/bigint-v2.d.ts +1 -1
- package/dist/validators/custom.d.ts +21 -1
- package/dist/validators/custom.js +1 -1
- package/dist/validators/date-v2.d.ts +1 -1
- package/dist/validators/number-v2.d.ts +1 -1
- package/dist/validators/number-v2.js +1 -1
- package/dist/validators/object-v2.d.ts +5 -5
- package/dist/validators/object.js +1 -1
- package/dist/validators/promise.d.ts +7 -0
- package/dist/validators/promise.js +1 -1
- package/dist/validators/string-formats.d.ts +14 -1
- package/dist/validators/string-formats.js +1 -1
- package/dist/validators/string-v2.d.ts +2 -2
- package/dist/validators/string.d.ts +10 -0
- package/dist/validators/string.js +1 -1
- package/dist/validators/union-v2.d.ts +1 -1
- package/package.json +246 -245
- package/dist/chunks/index-CKPStM3V.js +0 -1
- package/dist/cjs/chunks/index-lejEpLfv.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../../locales/ar.cjs"),r=require("../../locales/bn.cjs"),s=require("../../locales/da.cjs"),o=require("../../locales/de.cjs"),t=require("../../locales/en.cjs"),p=require("../../locales/es.cjs"),l=require("../../locales/fi.cjs"),
|
|
1
|
+
"use strict";var e=require("../../locales/ar.cjs"),r=require("../../locales/bn.cjs"),s=require("../../locales/da.cjs"),o=require("../../locales/de.cjs"),t=require("../../locales/en.cjs"),p=require("../../locales/es.cjs"),l=require("../../locales/fi.cjs"),c=require("../../locales/fr.cjs"),x=require("../../locales/gu.cjs"),a=require("../../locales/hi.cjs"),i=require("../../locales/id.cjs"),u=require("../../locales/it.cjs"),j=require("../../locales/ja.cjs"),q=require("../../locales/kn.cjs"),n=require("../../locales/ko.cjs"),h=require("../../locales/ne.cjs"),k=require("../../locales/nl.cjs"),d=require("../../locales/no.cjs"),f=require("../../locales/pl.cjs"),v=require("../../locales/pt.cjs"),g=require("../../locales/pt-BR-v4.cjs"),z=require("../../locales/ru.cjs"),b=require("../../locales/sk.cjs"),m=require("../../locales/sv.cjs"),B=require("../../locales/tg.cjs"),R=require("../../locales/th.cjs"),y=require("../../locales/tr.cjs"),C=require("../../locales/vi.cjs"),A=require("../../locales/zh.cjs");const N=()=>t.en,T=N,W=N,w=N,D=N,E=N,F=N,G=N,H=N,I=N,J=N,K=N,L=N,M=N,O=N,P=N,Q=N,S=N,U=N,V=N,X=N,Y=N,Z=N,$=N,_=N,ee=N,re=N,se=N,oe=N,te=N,pe=N,le=N,ce=N;exports.ar=()=>e.ar,exports.az=T,exports.be=W,exports.bg=w,exports.bn=()=>r.bn,exports.ca=D,exports.ckb=E,exports.cs=F,exports.da=()=>s.da,exports.de=()=>o.de,exports.el=G,exports.en=()=>t.en,exports.eo=H,exports.es=()=>p.es,exports.fa=I,exports.fi=()=>l.fi,exports.fr=()=>c.fr,exports.frCA=()=>c.fr,exports.gu=()=>x.gu,exports.he=J,exports.hi=()=>a.hi,exports.hr=K,exports.hu=L,exports.hy=M,exports.id=()=>i.id,exports.is=O,exports.it=()=>u.it,exports.ja=()=>j.ja,exports.ka=P,exports.kh=Q,exports.km=S,exports.kn=()=>q.kn,exports.ko=()=>n.ko,exports.lt=U,exports.mk=V,exports.ms=X,exports.ne=()=>h.ne,exports.nl=()=>k.nl,exports.nn=Y,exports.no=()=>d.no,exports.ota=Z,exports.pl=()=>f.pl,exports.ps=$,exports.pt=()=>v.pt,exports.ptBR=()=>g.ptBR,exports.ro=_,exports.ru=()=>z.ru,exports.sk=()=>b.sk,exports.sl=ee,exports.sv=()=>m.sv,exports.ta=re,exports.tg=()=>B.tg,exports.th=()=>R.th,exports.tk=se,exports.tr=()=>y.tr,exports.ua=oe,exports.uk=te,exports.ur=pe,exports.uz=le,exports.vi=()=>C.vi,exports.yo=ce,exports.zhCN=()=>A.zh,exports.zhTW=()=>A.zh;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../v4-mini/index.cjs"),r=require("../../index.cjs"),o=require("../../compat/result.cjs"),t=require("../../validators/base.cjs"),s=require("../../chunks/errors-core-C0mA6tfa.cjs"),i=require("../../validators/intersection.cjs"),p=require("../../validators/any.cjs"),a=require("../../validators/array.cjs"),n=require("../../validators/string-formats.cjs"),l=require("../../validators/bigint.cjs"),d=require("../../validators/boolean.cjs"),x=require("../../validators/codec.cjs"),c=require("../../compile.cjs"),u=require("../../validators/custom.cjs"),m=require("../../validators/date.cjs"),g=require("../../validators/discriminated-union.cjs"),V=require("../../validators/enum.cjs"),Z=require("../../validators/file.cjs"),y=require("../../validators/function.cjs"),v=require("../../validators/json.cjs"),j=require("../../validators/lazy.cjs"),S=require("../../validators/literal.cjs"),f=require("../../validators/map.cjs"),q=require("../../validators/nan.cjs"),M=require("../../validators/never.cjs"),b=require("../../validators/null.cjs"),F=require("../../validators/number.cjs"),T=require("../../validators/object.cjs"),h=require("../../validators/promise.cjs"),E=require("../../validators/record.cjs"),L=require("../../validators/set.cjs"),U=require("../../validators/string.cjs"),C=require("../../validators/symbol.cjs"),D=require("../../validators/template-literal.cjs"),I=require("../../validators/tuple.cjs"),B=require("../../validators/undefined.cjs"),A=require("../../validators/union.cjs"),O=require("../../validators/unknown.cjs"),N=require("../../validators/void.cjs"),R=require("../../validators/xor.cjs"),P=require("../../chunks/index-ZjHAxYdA.cjs"),w=require("../../pigment.cjs"),k=require("../../compat/emitter.cjs"),z=require("../../kernel.cjs"),J=require("../../errors.cjs"),K=require("../../locales/runtime.cjs"),_=require("../../registry.cjs"),X=require("../../chunks/index-lejEpLfv.cjs");require("../../validators/string-v2.cjs"),require("../../chunks/ip-validation-BZqPamPC.cjs"),require("../../locales/en.cjs"),require("../../validators/number-v2.cjs"),require("../../validators/date-v2.cjs"),require("../../validators/bigint-v2.cjs"),require("../../validators/array-v2.cjs"),require("../../validators/union-v2.cjs"),require("../../validators/wrapper-v2.cjs"),require("../../validators/leaf-v2.cjs"),require("../../validators/composite-v2.cjs"),require("../../validators/string-bool.cjs"),require("../../validators/base64.cjs"),require("../../validators/hex.cjs"),require("../../validators/uint8array.cjs"),require("../../coercion/index.cjs"),require("../../chunks/security-aXZVI7qW.cjs"),require("../../locales/tr.cjs"),require("../../locales/es.cjs"),require("../../locales/fr.cjs"),require("../../locales/de.cjs"),require("../../locales/it.cjs"),require("../../locales/pt.cjs"),require("../../locales/ru.cjs"),require("../../locales/ja.cjs"),require("../../locales/ko.cjs"),require("../../locales/zh.cjs"),require("../../locales/ar.cjs"),require("../../locales/hi.cjs"),require("../../locales/nl.cjs"),require("../../locales/pl.cjs"),require("../../locales/da.cjs"),require("../../locales/sv.cjs"),require("../../locales/no.cjs"),require("../../locales/fi.cjs"),require("../../locales/th.cjs"),require("../../locales/vi.cjs"),require("../../locales/id.cjs"),require("../../locales/bn.cjs"),require("../../locales/gu.cjs"),require("../../locales/kn.cjs"),require("../../locales/ne.cjs"),require("../../locales/sk.cjs"),require("../../locales/sw.cjs"),require("../../locales/af.cjs"),require("../../locales/pt-BR.cjs"),require("../../locales/es-MX.cjs"),exports._default=e._default,exports.catchall=e.catchall,exports.exactPartial=e.exactPartial,exports.extend=e.extend,exports.maximum=e.maximum,exports.merge=e.merge,exports.minimum=e.minimum,exports.omit=e.omit,exports.partial=e.partial,exports.pick=e.pick,exports.required=e.required,exports.safeExtend=e.safeExtend,exports.$brand=r.$brand,exports.$input=r.$input,exports.$output=r.$output,exports.NEVER=r.NEVER,exports.TimePrecision=r.TimePrecision,exports.ZodFirstPartyTypeKind=r.ZodFirstPartyTypeKind,exports.ZodIssueCode=r.ZodIssueCode,exports.ZodLikeError=r.ZodLikeError,exports._ZodString=r._ZodString,exports._function=r._function,exports.any=r.any,exports.array=r.array,exports.base64=r.base64,exports.base64Bytes=r.base64Bytes,exports.base64url=r.base64url,exports.bigint=r.bigint,exports.boolean=r.boolean,exports.catch=r.catch,exports.check=r.check,exports.cidrv4=r.cidrv4,exports.cidrv6=r.cidrv6,exports.clone=r.clone,exports.codec=r.codec,exports.coerce=r.coerce,exports.config=r.config,exports.core=r.core,exports.createLogger=r.createLogger,exports.createNoOpLogger=r.createNoOpLogger,exports.creditCard=r.creditCard,exports.cuid=r.cuid,exports.cuid2=r.cuid2,exports.custom=r.custom,exports.date=r.date,exports.decode=r.decode,exports.decodeAsync=r.decodeAsync,exports.deepPartial=r.deepPartial,exports.default=r.default,exports.describe=r.describe,exports.disableLogging=r.disableLogging,exports.discriminatedUnion=r.discriminatedUnion,exports.e164=r.e164,exports.email=r.email,exports.emoji=r.emoji,exports.enableDebug=r.enableDebug,exports.encode=r.encode,exports.encodeAsync=r.encodeAsync,exports.endsWith=r.endsWith,exports.enum=r.enum,exports.exactOptional=r.exactOptional,exports.file=r.file,exports.float32=r.float32,exports.float64=r.float64,exports.formatError=r.formatError,exports.fromJSONSchema=r.fromJSONSchema,exports.function=r._function,exports.getErrorMap=r.getErrorMap,exports.getLogger=r.getLogger,exports.gt=r.gt,exports.gte=r.gte,exports.guid=r.guid,exports.hash=r.hash,exports.hex=r.hex,exports.hexBytes=r.hexBytes,exports.hostname=r.hostname,exports.httpUrl=r.httpUrl,exports.includes=r.includes,exports.initLogger=r.initLogger,exports.input=r.input,exports.instanceof=r.instanceof,exports.int=r.int,exports.int32=r.int32,exports.int64=r.int64,exports.intersection=r.intersection,exports.ipv4=r.ipv4,exports.ipv6=r.ipv6,exports.iso=r.iso,exports.json=r.json,exports.jwt=r.jwt,exports.keyof=r.keyof,exports.ksuid=r.ksuid,exports.lazy=r.lazy,exports.length=r.length,exports.literal=r.literal,exports.locales=r.locales,exports.looseObject=r.looseObject,exports.looseRecord=r.looseRecord,exports.lowercase=r.lowercase,exports.lt=r.lt,exports.lte=r.lte,exports.mac=r.mac,exports.map=r.map,exports.mapSchema=r.mapSchema,exports.maxLength=r.maxLength,exports.maxSize=r.maxSize,exports.meta=r.meta,exports.mime=r.mime,exports.minLength=r.minLength,exports.minSize=r.minSize,exports.multipleOf=r.multipleOf,exports.nan=r.nan,exports.nanoid=r.nanoid,exports.nativeEnum=r.nativeEnum,exports.negative=r.negative,exports.never=r.never,exports.nonnegative=r.nonnegative,exports.nonoptional=r.nonoptional,exports.nonpositive=r.nonpositive,exports.normalize=r.normalize,exports.null=r.null,exports.nullable=r.nullable,exports.nullish=r.nullish,exports.number=r.number,exports.object=r.object,exports.optional=r.optional,exports.output=r.output,exports.overwrite=r.overwrite,exports.parse=r.parse,exports.parseAsync=r.parseAsync,exports.partialRecord=r.partialRecord,exports.pipe=r.pipe,exports.positive=r.positive,exports.prefault=r.prefault,exports.preprocess=r.preprocess,exports.promise=r.promise,exports.property=r.property,exports.readonly=r.readonly,exports.record=r.record,exports.refine=r.refine,exports.regex=r.regex,exports.regexes=r.regexes,exports.safeDecode=r.safeDecode,exports.safeDecodeAsync=r.safeDecodeAsync,exports.safeEncode=r.safeEncode,exports.safeEncodeAsync=r.safeEncodeAsync,exports.safeParse=r.safeParse,exports.safeParseAsync=r.safeParseAsync,exports.set=r.set,exports.setErrorMap=r.setErrorMap,exports.setLogLevel=r.setLogLevel,exports.size=r.size,exports.slugify=r.slugify,exports.startsWith=r.startsWith,exports.strictObject=r.strictObject,exports.string=r.string,exports.stringFormat=r.stringFormat,exports.stringbool=r.stringbool,exports.superRefine=r.superRefine,exports.symbol=r.symbol,exports.templateLiteral=r.templateLiteral,exports.toJSONSchema=r.toJSONSchema,exports.toLowerCase=r.toLowerCase,exports.toUpperCase=r.toUpperCase,exports.toZodError=r.toZodError,exports.toZodSafeResult=r.toZodSafeResult,exports.transform=r.transform,exports.trim=r.trim,exports.tuple=r.tuple,exports.uint32=r.uint32,exports.uint64=r.uint64,exports.uint8Array=r.uint8Array,exports.ulid=r.ulid,exports.undefined=r.undefined,exports.union=r.union,exports.unknown=r.unknown,exports.uppercase=r.uppercase,exports.url=r.url,exports.util=r.util,exports.uuid=r.uuid,exports.uuidv4=r.uuidv4,exports.uuidv6=r.uuidv6,exports.uuidv7=r.uuidv7,exports.v=r.default,exports.vV2=r.vV2,exports.void=r.void,exports.xid=r.xid,exports.xor=r.xor,exports.z=r.z,exports.Err=o.Err,exports.Ok=o.Ok,exports.ResultUtils=o.ResultUtils,exports.all=o.all,exports.failure=o.failure,exports.flatMap=o.flatMap,exports.fromNullable=o.fromNullable,exports.isErr=o.isErr,exports.isOk=o.isOk,exports.isResult=o.isResult,exports.mapErr=o.mapErr,exports.match=o.match,exports.success=o.success,exports.tryCatch=o.tryCatch,exports.tryCatchAsync=o.tryCatchAsync,exports.unwrap=o.unwrap,exports.unwrapOr=o.unwrapOr,exports.VldBase=t.VldBase,exports.VldMeta=t.VldMeta,exports.ZodBranded=t.VldBrand,exports.ZodCatch=t.VldCatch,exports.ZodDefault=t.VldDefault,exports.ZodExactOptional=t.VldExactOptional,exports.ZodMeta=t.VldMeta,exports.ZodMiniBrand=t.VldBrand,exports.ZodMiniCatch=t.VldCatch,exports.ZodMiniDefault=t.VldDefault,exports.ZodMiniExactOptional=t.VldExactOptional,exports.ZodMiniNonOptional=t.VldRefine,exports.ZodMiniNullable=t.VldNullable,exports.ZodMiniOptional=t.VldOptional,exports.ZodMiniPipe=t.VldPipe,exports.ZodMiniPrefault=t.VldPrefault,exports.ZodMiniReadonly=t.VldReadonly,exports.ZodMiniTransform=t.VldTransform,exports.ZodMiniType=t.VldBase,exports.ZodNonOptional=t.VldRefine,exports.ZodNullable=t.VldNullable,exports.ZodOptional=t.VldOptional,exports.ZodPipe=t.VldPipe,exports.ZodPrefault=t.VldPrefault,exports.ZodPreprocess=t.VldPreprocess,exports.ZodReadonly=t.VldReadonly,exports.ZodTransform=t.VldTransform,exports.ZodType=t.VldBase,exports.VldError=s.VldError,exports.ZodError=s.VldError,exports.ZodRealError=s.VldError,exports.VldIntersection=i.VldIntersection,exports.ZodIntersection=i.VldIntersection,exports.ZodMiniIntersection=i.VldIntersection,exports.ZodAny=p.VldAny,exports.ZodMiniAny=p.VldAny,exports.ZodArray=a.VldArray,exports.ZodMiniArray=a.VldArray,exports.ZodBase64=n.VldStringFormat,exports.ZodBase64URL=n.VldStringFormat,exports.ZodCIDRv4=n.VldStringFormat,exports.ZodCIDRv6=n.VldStringFormat,exports.ZodCUID=n.VldStringFormat,exports.ZodCUID2=n.VldStringFormat,exports.ZodCreditCard=n.VldStringFormat,exports.ZodCustomStringFormat=n.VldStringFormat,exports.ZodE164=n.VldStringFormat,exports.ZodEmail=n.VldStringFormat,exports.ZodEmoji=n.VldStringFormat,exports.ZodGUID=n.VldStringFormat,exports.ZodIPv4=n.VldStringFormat,exports.ZodIPv6=n.VldStringFormat,exports.ZodISODate=n.VldStringFormat,exports.ZodISODateTime=n.VldStringFormat,exports.ZodISODuration=n.VldStringFormat,exports.ZodISOTime=n.VldStringFormat,exports.ZodJWT=n.VldStringFormat,exports.ZodKSUID=n.VldStringFormat,exports.ZodMAC=n.VldStringFormat,exports.ZodMiniBase64=n.VldStringFormat,exports.ZodMiniBase64URL=n.VldStringFormat,exports.ZodMiniCIDRv4=n.VldStringFormat,exports.ZodMiniCIDRv6=n.VldStringFormat,exports.ZodMiniCUID=n.VldStringFormat,exports.ZodMiniCUID2=n.VldStringFormat,exports.ZodMiniCreditCard=n.VldStringFormat,exports.ZodMiniCustomStringFormat=n.VldStringFormat,exports.ZodMiniE164=n.VldStringFormat,exports.ZodMiniEmail=n.VldStringFormat,exports.ZodMiniEmoji=n.VldStringFormat,exports.ZodMiniGUID=n.VldStringFormat,exports.ZodMiniIPv4=n.VldStringFormat,exports.ZodMiniIPv6=n.VldStringFormat,exports.ZodMiniISODate=n.VldStringFormat,exports.ZodMiniISODateTime=n.VldStringFormat,exports.ZodMiniISODuration=n.VldStringFormat,exports.ZodMiniISOTime=n.VldStringFormat,exports.ZodMiniJWT=n.VldStringFormat,exports.ZodMiniKSUID=n.VldStringFormat,exports.ZodMiniMAC=n.VldStringFormat,exports.ZodMiniNanoID=n.VldStringFormat,exports.ZodMiniStringFormat=n.VldStringFormat,exports.ZodMiniULID=n.VldStringFormat,exports.ZodMiniURL=n.VldStringFormat,exports.ZodMiniUUID=n.VldStringFormat,exports.ZodMiniXID=n.VldStringFormat,exports.ZodNanoID=n.VldStringFormat,exports.ZodStringFormat=n.VldStringFormat,exports.ZodULID=n.VldStringFormat,exports.ZodURL=n.VldStringFormat,exports.ZodUUID=n.VldStringFormat,exports.ZodXID=n.VldStringFormat,exports.ZodBigInt=l.VldBigInt,exports.ZodBigIntFormat=l.VldBigInt,exports.ZodMiniBigInt=l.VldBigInt,exports.ZodMiniBigIntFormat=l.VldBigInt,exports.ZodBoolean=d.VldBoolean,exports.ZodMiniBoolean=d.VldBoolean,exports.ZodCodec=x.VldCodec,exports.ZodMiniCodec=x.VldCodec,exports.ZodCompileAsyncError=c.ZodCompileAsyncError,exports.ZodCompileError=c.ZodCompileError,exports.ZodCompileUnsupportedError=c.ZodCompileUnsupportedError,exports.compile=c.compile,exports.getDiscriminatedOption=c.getDiscriminatedOption,exports.memoizer=c.memoizer,exports.properties=c.properties,exports.toZod=c.toZod,exports.validate=c.validate,exports.validateAsync=c.validateAsync,exports.zodCompileFn=c.compileFn,exports.ZodCustom=u.VldCustom,exports.ZodMiniCustom=u.VldCustom,exports.ZodMiniSuccess=u.VldCustom,exports.ZodSuccess=u.VldCustom,exports.ZodDate=m.VldDate,exports.ZodMiniDate=m.VldDate,exports.ZodDiscriminatedUnion=g.VldDiscriminatedUnion,exports.ZodMiniDiscriminatedUnion=g.VldDiscriminatedUnion,exports.ZodEnum=V.VldEnum,exports.ZodMiniEnum=V.VldEnum,exports.ZodFile=Z.VldFile,exports.ZodMiniFile=Z.VldFile,exports.ZodFunction=y.VldFunction,exports.ZodMiniFunction=y.VldFunction,exports.ZodJSON=v.VldJson,exports.ZodLazy=j.VldLazy,exports.ZodMiniLazy=j.VldLazy,exports.ZodLiteral=S.VldLiteral,exports.ZodMiniLiteral=S.VldLiteral,exports.ZodMap=f.VldMap,exports.ZodMiniMap=f.VldMap,exports.ZodMiniNaN=q.VldNan,exports.ZodNaN=q.VldNan,exports.ZodMiniNever=M.VldNever,exports.ZodNever=M.VldNever,exports.ZodMiniNull=b.VldNull,exports.ZodNull=b.VldNull,exports.ZodMiniNumber=F.VldNumber,exports.ZodMiniNumberFormat=F.VldNumber,exports.ZodNumber=F.VldNumber,exports.ZodNumberFormat=F.VldNumber,exports.ZodMiniObject=T.VldObject,exports.ZodObject=T.VldObject,exports.ZodMiniPromise=h.VldPromise,exports.ZodPromise=h.VldPromise,exports.ZodMiniRecord=E.VldRecord,exports.ZodRecord=E.VldRecord,exports.ZodMiniSet=L.VldSet,exports.ZodSet=L.VldSet,exports.ZodMiniString=U.VldString,exports.ZodString=U.VldString,exports.ZodMiniSymbol=C.VldSymbol,exports.ZodSymbol=C.VldSymbol,exports.ZodMiniTemplateLiteral=D.VldTemplateLiteral,exports.ZodTemplateLiteral=D.VldTemplateLiteral,exports.ZodMiniTuple=I.VldTuple,exports.ZodTuple=I.VldTuple,exports.ZodMiniUndefined=B.VldUndefined,exports.ZodUndefined=B.VldUndefined,exports.ZodMiniUnion=A.VldUnion,exports.ZodUnion=A.VldUnion,exports.ZodMiniUnknown=O.VldUnknown,exports.ZodUnknown=O.VldUnknown,exports.ZodMiniVoid=N.VldVoid,exports.ZodVoid=N.VldVoid,exports.ZodMiniXor=R.VldXor,exports.ZodXor=R.VldXor,exports.base64Json=P.base64Json,exports.base64ToBytes=P.base64ToBytes,exports.base64ToUint8Array=P.base64ToUint8Array,exports.base64UrlToBytes=P.base64UrlToBytes,exports.base64urlToBytes=P.base64urlToBytes,exports.bytesToUtf8=P.bytesToUtf8,exports.epochMillisToDate=P.epochMillisToDate,exports.epochSecondsToDate=P.epochSecondsToDate,exports.hexLowerToBytes=P.hexLowerToBytes,exports.hexToBytes=P.hexToBytes,exports.hexToUint8Array=P.hexToUint8Array,exports.invertCodec=P.invertCodec,exports.isoDatetimeToDate=P.isoDatetimeToDate,exports.jsonCodec=P.jsonCodec,exports.jwtPayload=P.jwtPayload,exports.numberToBigInt=P.numberToBigInt,exports.stringToBigInt=P.stringToBigInt,exports.stringToBoolean=P.stringToBoolean,exports.stringToHttpURL=P.stringToHttpURL,exports.stringToInt=P.stringToInt,exports.stringToNumber=P.stringToNumber,exports.stringToURL=P.stringToURL,exports.stringToUint8Array=P.stringToUint8Array,exports.uint8ArrayToBase64=P.uint8ArrayToBase64,exports.uint8ArrayToBase64Url=P.uint8ArrayToBase64Url,exports.uint8ArrayToHex=P.uint8ArrayToHex,exports.uint8ArrayToString=P.uint8ArrayToString,exports.uriComponent=P.uriComponent,exports.utf8ToBytes=P.utf8ToBytes,exports.blue=w.blue,exports.bold=w.bold,exports.createTheme=w.createTheme,exports.cyan=w.cyan,exports.dim=w.dim,exports.gray=w.gray,exports.green=w.green,exports.grey=w.grey,exports.italic=w.italic,exports.magenta=w.magenta,exports.pigment=w.default,exports.red=w.red,exports.strip=w.strip,exports.supportsColor=w.supportsColor,exports.underline=w.underline,exports.vldTheme=w.vldTheme,exports.white=w.white,exports.yellow=w.yellow,exports.createEmitter=k.createEmitter,exports.createEventBus=k.createEventBus,exports.withEmitter=k.withEmitter,exports.createVldKernel=z.createVldKernel,exports.definePlugin=z.definePlugin,exports.getVldKernel=z.getVldKernel,exports.resetVldKernel=z.resetVldKernel,exports.usePlugin=z.usePlugin,exports.flattenError=J.flattenError,exports.prettifyError=J.prettifyError,exports.prettifyErrorColored=J.prettifyErrorColored,exports.prettifyErrorPlain=J.prettifyErrorPlain,exports.treeifyError=J.treeifyError,exports.getLocale=K.getLocale,exports.getMessages=K.getMessages,exports.getSupportedLocales=K.getSupportedLocales,exports.isLocaleLoaded=K.isLocaleLoaded,exports.isLocaleSupported=K.isLocaleSupported,exports.registerLocale=K.registerLocale,exports.setLocale=K.setLocale,exports.globalRegistry=_.globalRegistry,exports.registry=_.registry,exports.setLocaleAsync=X.setLocaleAsync;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../v4-mini/index.cjs"),r=require("../../index.cjs"),o=require("../../compile.cjs"),t=require("../../compat/result.cjs"),s=require("../../validators/base.cjs"),i=require("../../chunks/errors-core-C0mA6tfa.cjs"),p=require("../../validators/intersection.cjs"),a=require("../../validators/any.cjs"),n=require("../../validators/array.cjs"),d=require("../../validators/string-formats.cjs"),l=require("../../validators/bigint.cjs"),x=require("../../validators/boolean.cjs"),c=require("../../validators/codec.cjs"),u=require("../../validators/custom.cjs"),m=require("../../validators/date.cjs"),g=require("../../validators/discriminated-union.cjs"),V=require("../../validators/enum.cjs"),Z=require("../../validators/file.cjs"),y=require("../../validators/function.cjs"),j=require("../../validators/json.cjs"),v=require("../../validators/lazy.cjs"),S=require("../../validators/literal.cjs"),f=require("../../validators/map.cjs"),M=require("../../validators/nan.cjs"),q=require("../../validators/never.cjs"),b=require("../../validators/null.cjs"),F=require("../../validators/number.cjs"),T=require("../../validators/object.cjs"),h=require("../../validators/promise.cjs"),E=require("../../validators/record.cjs"),I=require("../../validators/set.cjs"),L=require("../../validators/string.cjs"),C=require("../../validators/symbol.cjs"),U=require("../../validators/template-literal.cjs"),D=require("../../validators/tuple.cjs"),B=require("../../validators/undefined.cjs"),A=require("../../validators/union.cjs"),N=require("../../validators/unknown.cjs"),O=require("../../validators/void.cjs"),P=require("../../validators/xor.cjs"),R=require("../../chunks/index-ZjHAxYdA.cjs"),w=require("../../pigment.cjs"),k=require("../../compat/emitter.cjs"),z=require("../../kernel.cjs"),_=require("../../errors.cjs"),J=require("../../locales/runtime.cjs"),K=require("../../registry.cjs"),X=require("../../chunks/index-DJwZFerZ.cjs");require("../../validators/string-v2.cjs"),require("../../chunks/ip-validation-BZqPamPC.cjs"),require("../../locales/en.cjs"),require("../../validators/number-v2.cjs"),require("../../validators/date-v2.cjs"),require("../../validators/bigint-v2.cjs"),require("../../validators/array-v2.cjs"),require("../../validators/union-v2.cjs"),require("../../validators/wrapper-v2.cjs"),require("../../validators/leaf-v2.cjs"),require("../../validators/composite-v2.cjs"),require("../../validators/string-bool.cjs"),require("../../validators/base64.cjs"),require("../../validators/hex.cjs"),require("../../validators/uint8array.cjs"),require("../../coercion/index.cjs"),require("../../chunks/security-aXZVI7qW.cjs"),require("../../locales/tr.cjs"),require("../../locales/es.cjs"),require("../../locales/fr.cjs"),require("../../locales/de.cjs"),require("../../locales/it.cjs"),require("../../locales/pt.cjs"),require("../../locales/ru.cjs"),require("../../locales/ja.cjs"),require("../../locales/ko.cjs"),require("../../locales/zh.cjs"),require("../../locales/ar.cjs"),require("../../locales/hi.cjs"),require("../../locales/nl.cjs"),require("../../locales/pl.cjs"),require("../../locales/da.cjs"),require("../../locales/sv.cjs"),require("../../locales/no.cjs"),require("../../locales/fi.cjs"),require("../../locales/th.cjs"),require("../../locales/vi.cjs"),require("../../locales/id.cjs"),require("../../locales/bn.cjs"),require("../../locales/gu.cjs"),require("../../locales/kn.cjs"),require("../../locales/ne.cjs"),require("../../locales/sk.cjs"),require("../../locales/tg.cjs"),require("../../locales/sw.cjs"),require("../../locales/af.cjs"),require("../../locales/pt-BR.cjs"),require("../../locales/es-MX.cjs"),exports._default=e._default,exports.catchall=e.catchall,exports.exactPartial=e.exactPartial,exports.extend=e.extend,exports.maximum=e.maximum,exports.merge=e.merge,exports.minimum=e.minimum,exports.omit=e.omit,exports.partial=e.partial,exports.pick=e.pick,exports.required=e.required,exports.safeExtend=e.safeExtend,exports.$brand=r.$brand,exports.$input=r.$input,exports.$output=r.$output,exports.NEVER=r.NEVER,exports.TimePrecision=r.TimePrecision,exports.ZodFirstPartyTypeKind=r.ZodFirstPartyTypeKind,exports.ZodIssueCode=r.ZodIssueCode,exports.ZodLikeError=r.ZodLikeError,exports._ZodString=r._ZodString,exports._function=r._function,exports.any=r.any,exports.array=r.array,exports.base64=r.base64,exports.base64Bytes=r.base64Bytes,exports.base64url=r.base64url,exports.bigint=r.bigint,exports.boolean=r.boolean,exports.catch=r.catch,exports.check=r.check,exports.cidrv4=r.cidrv4,exports.cidrv6=r.cidrv6,exports.clone=r.clone,exports.codec=r.codec,exports.coerce=r.coerce,exports.config=r.config,exports.core=r.core,exports.createLogger=r.createLogger,exports.createNoOpLogger=r.createNoOpLogger,exports.creditCard=r.creditCard,exports.cuid=r.cuid,exports.cuid2=r.cuid2,exports.currencyCode=r.currencyCode,exports.custom=r.custom,exports.date=r.date,exports.decode=r.decode,exports.decodeAsync=r.decodeAsync,exports.deepPartial=r.deepPartial,exports.default=r.default,exports.describe=r.describe,exports.disableLogging=r.disableLogging,exports.discriminatedUnion=r.discriminatedUnion,exports.e164=r.e164,exports.email=r.email,exports.emoji=r.emoji,exports.enableDebug=r.enableDebug,exports.encode=r.encode,exports.encodeAsync=r.encodeAsync,exports.endsWith=r.endsWith,exports.enum=r.enum,exports.exactOptional=r.exactOptional,exports.file=r.file,exports.float32=r.float32,exports.float64=r.float64,exports.formatError=r.formatError,exports.fromJSONSchema=r.fromJSONSchema,exports.function=r._function,exports.getErrorMap=r.getErrorMap,exports.getLogger=r.getLogger,exports.gt=r.gt,exports.gte=r.gte,exports.guid=r.guid,exports.hash=r.hash,exports.hex=r.hex,exports.hexBytes=r.hexBytes,exports.hostname=r.hostname,exports.httpUrl=r.httpUrl,exports.iban=r.iban,exports.includes=r.includes,exports.initLogger=r.initLogger,exports.input=r.input,exports.instanceof=r.instanceof,exports.int=r.int,exports.int32=r.int32,exports.int64=r.int64,exports.intersection=r.intersection,exports.ipv4=r.ipv4,exports.ipv6=r.ipv6,exports.iso=r.iso,exports.json=r.json,exports.jwt=r.jwt,exports.keyof=r.keyof,exports.ksuid=r.ksuid,exports.lazy=r.lazy,exports.length=r.length,exports.literal=r.literal,exports.locales=r.locales,exports.looseObject=r.looseObject,exports.looseRecord=r.looseRecord,exports.lowercase=r.lowercase,exports.lt=r.lt,exports.lte=r.lte,exports.mac=r.mac,exports.map=r.map,exports.mapSchema=r.mapSchema,exports.maxLength=r.maxLength,exports.maxSize=r.maxSize,exports.meta=r.meta,exports.mime=r.mime,exports.minLength=r.minLength,exports.minSize=r.minSize,exports.multipleOf=r.multipleOf,exports.nan=r.nan,exports.nanoid=r.nanoid,exports.nativeEnum=r.nativeEnum,exports.negative=r.negative,exports.never=r.never,exports.nonnegative=r.nonnegative,exports.nonoptional=r.nonoptional,exports.nonpositive=r.nonpositive,exports.normalize=r.normalize,exports.null=r.null,exports.nullable=r.nullable,exports.nullish=r.nullish,exports.number=r.number,exports.object=r.object,exports.optional=r.optional,exports.output=r.output,exports.overwrite=r.overwrite,exports.parse=r.parse,exports.parseAsync=r.parseAsync,exports.partialRecord=r.partialRecord,exports.pipe=r.pipe,exports.positive=r.positive,exports.prefault=r.prefault,exports.preprocess=r.preprocess,exports.promise=r.promise,exports.property=r.property,exports.readonly=r.readonly,exports.record=r.record,exports.refine=r.refine,exports.regex=r.regex,exports.regexes=r.regexes,exports.safeDecode=r.safeDecode,exports.safeDecodeAsync=r.safeDecodeAsync,exports.safeEncode=r.safeEncode,exports.safeEncodeAsync=r.safeEncodeAsync,exports.safeParse=r.safeParse,exports.safeParseAsync=r.safeParseAsync,exports.set=r.set,exports.setErrorMap=r.setErrorMap,exports.setLogLevel=r.setLogLevel,exports.size=r.size,exports.slugify=r.slugify,exports.startsWith=r.startsWith,exports.strictObject=r.strictObject,exports.string=r.string,exports.stringFormat=r.stringFormat,exports.stringbool=r.stringbool,exports.superRefine=r.superRefine,exports.symbol=r.symbol,exports.templateLiteral=r.templateLiteral,exports.toJSONSchema=r.toJSONSchema,exports.toLowerCase=r.toLowerCase,exports.toUpperCase=r.toUpperCase,exports.toZodError=r.toZodError,exports.toZodSafeResult=r.toZodSafeResult,exports.transform=r.transform,exports.trim=r.trim,exports.tuple=r.tuple,exports.uint32=r.uint32,exports.uint64=r.uint64,exports.uint8Array=r.uint8Array,exports.ulid=r.ulid,exports.undefined=r.undefined,exports.union=r.union,exports.unknown=r.unknown,exports.uppercase=r.uppercase,exports.url=r.url,exports.util=r.util,exports.uuid=r.uuid,exports.uuidv4=r.uuidv4,exports.uuidv6=r.uuidv6,exports.uuidv7=r.uuidv7,exports.v=r.default,exports.vV2=r.vV2,exports.void=r.void,exports.xid=r.xid,exports.xor=r.xor,exports.z=r.z,exports.COMPILE_INVALID=o.COMPILE_INVALID,exports.INVALID=o.COMPILE_INVALID,exports.ZodCompileAsyncError=o.ZodCompileAsyncError,exports.ZodCompileError=o.ZodCompileError,exports.ZodCompileUnsupportedError=o.ZodCompileUnsupportedError,exports.compile=o.compile,exports.getDiscriminatedOption=o.getDiscriminatedOption,exports.memoizer=o.memoizer,exports.properties=o.properties,exports.toZod=o.toZod,exports.validate=o.validate,exports.validateAsync=o.validateAsync,exports.withParser=o.withParser,exports.zodCompileFn=o.compileFn,exports.Err=t.Err,exports.Ok=t.Ok,exports.ResultUtils=t.ResultUtils,exports.all=t.all,exports.failure=t.failure,exports.flatMap=t.flatMap,exports.fromNullable=t.fromNullable,exports.isErr=t.isErr,exports.isOk=t.isOk,exports.isResult=t.isResult,exports.mapErr=t.mapErr,exports.match=t.match,exports.success=t.success,exports.tryCatch=t.tryCatch,exports.tryCatchAsync=t.tryCatchAsync,exports.unwrap=t.unwrap,exports.unwrapOr=t.unwrapOr,exports.VldBase=s.VldBase,exports.VldMeta=s.VldMeta,exports.ZodBranded=s.VldBrand,exports.ZodCatch=s.VldCatch,exports.ZodDefault=s.VldDefault,exports.ZodExactOptional=s.VldExactOptional,exports.ZodMeta=s.VldMeta,exports.ZodMiniBrand=s.VldBrand,exports.ZodMiniCatch=s.VldCatch,exports.ZodMiniDefault=s.VldDefault,exports.ZodMiniExactOptional=s.VldExactOptional,exports.ZodMiniNonOptional=s.VldRefine,exports.ZodMiniNullable=s.VldNullable,exports.ZodMiniOptional=s.VldOptional,exports.ZodMiniPipe=s.VldPipe,exports.ZodMiniPrefault=s.VldPrefault,exports.ZodMiniReadonly=s.VldReadonly,exports.ZodMiniTransform=s.VldTransform,exports.ZodMiniType=s.VldBase,exports.ZodNonOptional=s.VldRefine,exports.ZodNullable=s.VldNullable,exports.ZodOptional=s.VldOptional,exports.ZodPipe=s.VldPipe,exports.ZodPrefault=s.VldPrefault,exports.ZodPreprocess=s.VldPreprocess,exports.ZodReadonly=s.VldReadonly,exports.ZodTransform=s.VldTransform,exports.ZodType=s.VldBase,exports.VldError=i.VldError,exports.ZodError=i.VldError,exports.ZodRealError=i.VldError,exports.VldIntersection=p.VldIntersection,exports.ZodIntersection=p.VldIntersection,exports.ZodMiniIntersection=p.VldIntersection,exports.ZodAny=a.VldAny,exports.ZodMiniAny=a.VldAny,exports.ZodArray=n.VldArray,exports.ZodMiniArray=n.VldArray,exports.ZodBase64=d.VldStringFormat,exports.ZodBase64URL=d.VldStringFormat,exports.ZodCIDRv4=d.VldStringFormat,exports.ZodCIDRv6=d.VldStringFormat,exports.ZodCUID=d.VldStringFormat,exports.ZodCUID2=d.VldStringFormat,exports.ZodCreditCard=d.VldStringFormat,exports.ZodCustomStringFormat=d.VldStringFormat,exports.ZodE164=d.VldStringFormat,exports.ZodEmail=d.VldStringFormat,exports.ZodEmoji=d.VldStringFormat,exports.ZodGUID=d.VldStringFormat,exports.ZodIBAN=d.VldStringFormat,exports.ZodIPv4=d.VldStringFormat,exports.ZodIPv6=d.VldStringFormat,exports.ZodISODate=d.VldStringFormat,exports.ZodISODateTime=d.VldStringFormat,exports.ZodISODuration=d.VldStringFormat,exports.ZodISOTime=d.VldStringFormat,exports.ZodJWT=d.VldStringFormat,exports.ZodKSUID=d.VldStringFormat,exports.ZodMAC=d.VldStringFormat,exports.ZodMiniBase64=d.VldStringFormat,exports.ZodMiniBase64URL=d.VldStringFormat,exports.ZodMiniCIDRv4=d.VldStringFormat,exports.ZodMiniCIDRv6=d.VldStringFormat,exports.ZodMiniCUID=d.VldStringFormat,exports.ZodMiniCUID2=d.VldStringFormat,exports.ZodMiniCreditCard=d.VldStringFormat,exports.ZodMiniCustomStringFormat=d.VldStringFormat,exports.ZodMiniE164=d.VldStringFormat,exports.ZodMiniEmail=d.VldStringFormat,exports.ZodMiniEmoji=d.VldStringFormat,exports.ZodMiniGUID=d.VldStringFormat,exports.ZodMiniIBAN=d.VldStringFormat,exports.ZodMiniIPv4=d.VldStringFormat,exports.ZodMiniIPv6=d.VldStringFormat,exports.ZodMiniISODate=d.VldStringFormat,exports.ZodMiniISODateTime=d.VldStringFormat,exports.ZodMiniISODuration=d.VldStringFormat,exports.ZodMiniISOTime=d.VldStringFormat,exports.ZodMiniJWT=d.VldStringFormat,exports.ZodMiniKSUID=d.VldStringFormat,exports.ZodMiniMAC=d.VldStringFormat,exports.ZodMiniNanoID=d.VldStringFormat,exports.ZodMiniStringFormat=d.VldStringFormat,exports.ZodMiniULID=d.VldStringFormat,exports.ZodMiniURL=d.VldStringFormat,exports.ZodMiniUUID=d.VldStringFormat,exports.ZodMiniXID=d.VldStringFormat,exports.ZodNanoID=d.VldStringFormat,exports.ZodStringFormat=d.VldStringFormat,exports.ZodULID=d.VldStringFormat,exports.ZodURL=d.VldStringFormat,exports.ZodUUID=d.VldStringFormat,exports.ZodXID=d.VldStringFormat,exports.isValidIBAN=d.isValidIBAN,exports.ZodBigInt=l.VldBigInt,exports.ZodBigIntFormat=l.VldBigInt,exports.ZodMiniBigInt=l.VldBigInt,exports.ZodMiniBigIntFormat=l.VldBigInt,exports.ZodBoolean=x.VldBoolean,exports.ZodMiniBoolean=x.VldBoolean,exports.ZodCodec=c.VldCodec,exports.ZodMiniCodec=c.VldCodec,exports.ZodCustom=u.VldCustom,exports.ZodInstanceOf=u.VldInstance,exports.ZodMiniCustom=u.VldCustom,exports.ZodMiniSuccess=u.VldCustom,exports.ZodSuccess=u.VldCustom,exports.ZodDate=m.VldDate,exports.ZodMiniDate=m.VldDate,exports.ZodDiscriminatedUnion=g.VldDiscriminatedUnion,exports.ZodMiniDiscriminatedUnion=g.VldDiscriminatedUnion,exports.ZodEnum=V.VldEnum,exports.ZodMiniEnum=V.VldEnum,exports.ZodFile=Z.VldFile,exports.ZodMiniFile=Z.VldFile,exports.ZodFunction=y.VldFunction,exports.ZodMiniFunction=y.VldFunction,exports.ZodJSON=j.VldJson,exports.ZodLazy=v.VldLazy,exports.ZodMiniLazy=v.VldLazy,exports.ZodLiteral=S.VldLiteral,exports.ZodMiniLiteral=S.VldLiteral,exports.ZodMap=f.VldMap,exports.ZodMiniMap=f.VldMap,exports.ZodMiniNaN=M.VldNan,exports.ZodNaN=M.VldNan,exports.ZodMiniNever=q.VldNever,exports.ZodNever=q.VldNever,exports.ZodMiniNull=b.VldNull,exports.ZodNull=b.VldNull,exports.ZodMiniNumber=F.VldNumber,exports.ZodMiniNumberFormat=F.VldNumber,exports.ZodNumber=F.VldNumber,exports.ZodNumberFormat=F.VldNumber,exports.ZodMiniObject=T.VldObject,exports.ZodObject=T.VldObject,exports.ZodMiniPromise=h.VldPromise,exports.ZodPromise=h.VldPromise,exports.ZodMiniRecord=E.VldRecord,exports.ZodRecord=E.VldRecord,exports.ZodMiniSet=I.VldSet,exports.ZodSet=I.VldSet,exports.ZodMiniString=L.VldString,exports.ZodString=L.VldString,exports.ZodMiniSymbol=C.VldSymbol,exports.ZodSymbol=C.VldSymbol,exports.ZodMiniTemplateLiteral=U.VldTemplateLiteral,exports.ZodTemplateLiteral=U.VldTemplateLiteral,exports.ZodMiniTuple=D.VldTuple,exports.ZodTuple=D.VldTuple,exports.ZodMiniUndefined=B.VldUndefined,exports.ZodUndefined=B.VldUndefined,exports.ZodMiniUnion=A.VldUnion,exports.ZodUnion=A.VldUnion,exports.ZodMiniUnknown=N.VldUnknown,exports.ZodUnknown=N.VldUnknown,exports.ZodMiniVoid=O.VldVoid,exports.ZodVoid=O.VldVoid,exports.ZodMiniXor=P.VldXor,exports.ZodXor=P.VldXor,exports.base64Json=R.base64Json,exports.base64ToBytes=R.base64ToBytes,exports.base64ToUint8Array=R.base64ToUint8Array,exports.base64UrlToBytes=R.base64UrlToBytes,exports.base64urlToBytes=R.base64urlToBytes,exports.bytesToUtf8=R.bytesToUtf8,exports.epochMillisToDate=R.epochMillisToDate,exports.epochSecondsToDate=R.epochSecondsToDate,exports.hexLowerToBytes=R.hexLowerToBytes,exports.hexToBytes=R.hexToBytes,exports.hexToUint8Array=R.hexToUint8Array,exports.invertCodec=R.invertCodec,exports.isoDatetimeToDate=R.isoDatetimeToDate,exports.jsonCodec=R.jsonCodec,exports.jwtPayload=R.jwtPayload,exports.numberToBigInt=R.numberToBigInt,exports.stringToBigInt=R.stringToBigInt,exports.stringToBoolean=R.stringToBoolean,exports.stringToHttpURL=R.stringToHttpURL,exports.stringToInt=R.stringToInt,exports.stringToNumber=R.stringToNumber,exports.stringToURL=R.stringToURL,exports.stringToUint8Array=R.stringToUint8Array,exports.uint8ArrayToBase64=R.uint8ArrayToBase64,exports.uint8ArrayToBase64Url=R.uint8ArrayToBase64Url,exports.uint8ArrayToHex=R.uint8ArrayToHex,exports.uint8ArrayToString=R.uint8ArrayToString,exports.uriComponent=R.uriComponent,exports.utf8ToBytes=R.utf8ToBytes,exports.blue=w.blue,exports.bold=w.bold,exports.createTheme=w.createTheme,exports.cyan=w.cyan,exports.dim=w.dim,exports.gray=w.gray,exports.green=w.green,exports.grey=w.grey,exports.italic=w.italic,exports.magenta=w.magenta,exports.pigment=w.default,exports.red=w.red,exports.strip=w.strip,exports.supportsColor=w.supportsColor,exports.underline=w.underline,exports.vldTheme=w.vldTheme,exports.white=w.white,exports.yellow=w.yellow,exports.createEmitter=k.createEmitter,exports.createEventBus=k.createEventBus,exports.withEmitter=k.withEmitter,exports.createVldKernel=z.createVldKernel,exports.definePlugin=z.definePlugin,exports.getVldKernel=z.getVldKernel,exports.resetVldKernel=z.resetVldKernel,exports.usePlugin=z.usePlugin,exports.flattenError=_.flattenError,exports.prettifyError=_.prettifyError,exports.prettifyErrorColored=_.prettifyErrorColored,exports.prettifyErrorPlain=_.prettifyErrorPlain,exports.treeifyError=_.treeifyError,exports.getLocale=J.getLocale,exports.getMessages=J.getMessages,exports.getSupportedLocales=J.getSupportedLocales,exports.isLocaleLoaded=J.isLocaleLoaded,exports.isLocaleSupported=J.isLocaleSupported,exports.registerLocale=J.registerLocale,exports.setLocale=J.setLocale,exports.globalRegistry=K.globalRegistry,exports.registry=K.registry,exports.setLocaleAsync=X.setLocaleAsync;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../index.cjs"),r=require("../compile.cjs"),o=require("../compat/result.cjs"),t=require("../validators/base.cjs"),s=require("../chunks/errors-core-C0mA6tfa.cjs"),i=require("../validators/intersection.cjs"),p=require("../validators/any.cjs"),a=require("../validators/array.cjs"),n=require("../validators/string-formats.cjs"),l=require("../validators/bigint.cjs"),d=require("../validators/boolean.cjs"),x=require("../validators/codec.cjs"),c=require("../validators/custom.cjs"),u=require("../validators/date.cjs"),m=require("../validators/discriminated-union.cjs"),g=require("../validators/enum.cjs"),V=require("../validators/file.cjs"),Z=require("../validators/function.cjs"),y=require("../validators/json.cjs"),j=require("../validators/lazy.cjs"),v=require("../validators/literal.cjs"),f=require("../validators/map.cjs"),S=require("../validators/nan.cjs"),q=require("../validators/never.cjs"),M=require("../validators/null.cjs"),b=require("../validators/number.cjs"),F=require("../validators/object.cjs"),T=require("../validators/promise.cjs"),h=require("../validators/record.cjs"),E=require("../validators/set.cjs"),L=require("../validators/string.cjs"),U=require("../validators/symbol.cjs"),C=require("../validators/template-literal.cjs"),D=require("../validators/tuple.cjs"),I=require("../validators/undefined.cjs"),B=require("../validators/union.cjs"),O=require("../validators/unknown.cjs"),A=require("../validators/void.cjs"),N=require("../validators/xor.cjs"),R=require("../chunks/index-ZjHAxYdA.cjs"),P=require("../pigment.cjs"),k=require("../compat/emitter.cjs"),w=require("../kernel.cjs"),z=require("../errors.cjs"),J=require("../locales/runtime.cjs"),K=require("../registry.cjs"),_=require("../chunks/index-lejEpLfv.cjs");function X(e){return Object.keys(e).filter(r=>e[r])}function W(e){return"string"==typeof e?e:e?.message||e?.error}require("../validators/string-v2.cjs"),require("../chunks/ip-validation-BZqPamPC.cjs"),require("../locales/en.cjs"),require("../validators/number-v2.cjs"),require("../validators/date-v2.cjs"),require("../validators/bigint-v2.cjs"),require("../validators/array-v2.cjs"),require("../validators/union-v2.cjs"),require("../validators/wrapper-v2.cjs"),require("../validators/leaf-v2.cjs"),require("../validators/composite-v2.cjs"),require("../validators/string-bool.cjs"),require("../validators/base64.cjs"),require("../validators/hex.cjs"),require("../validators/uint8array.cjs"),require("../coercion/index.cjs"),require("../chunks/security-aXZVI7qW.cjs"),require("../locales/tr.cjs"),require("../locales/es.cjs"),require("../locales/fr.cjs"),require("../locales/de.cjs"),require("../locales/it.cjs"),require("../locales/pt.cjs"),require("../locales/ru.cjs"),require("../locales/ja.cjs"),require("../locales/ko.cjs"),require("../locales/zh.cjs"),require("../locales/ar.cjs"),require("../locales/hi.cjs"),require("../locales/nl.cjs"),require("../locales/pl.cjs"),require("../locales/da.cjs"),require("../locales/sv.cjs"),require("../locales/no.cjs"),require("../locales/fi.cjs"),require("../locales/th.cjs"),require("../locales/vi.cjs"),require("../locales/id.cjs"),require("../locales/bn.cjs"),require("../locales/gu.cjs"),require("../locales/kn.cjs"),require("../locales/ne.cjs"),require("../locales/sk.cjs"),require("../locales/sw.cjs"),require("../locales/af.cjs"),require("../locales/pt-BR.cjs"),require("../locales/es-MX.cjs");exports.$brand=e.$brand,exports.$input=e.$input,exports.$output=e.$output,exports.NEVER=e.NEVER,exports.TimePrecision=e.TimePrecision,exports.ZodFirstPartyTypeKind=e.ZodFirstPartyTypeKind,exports.ZodIssueCode=e.ZodIssueCode,exports.ZodLikeError=e.ZodLikeError,exports._ZodString=e._ZodString,exports._function=e._function,exports.any=e.any,exports.array=e.array,exports.base64=e.base64,exports.base64Bytes=e.base64Bytes,exports.base64url=e.base64url,exports.bigint=e.bigint,exports.boolean=e.boolean,exports.catch=e.catch,exports.check=e.check,exports.cidrv4=e.cidrv4,exports.cidrv6=e.cidrv6,exports.clone=e.clone,exports.codec=e.codec,exports.coerce=e.coerce,exports.config=e.config,exports.core=e.core,exports.createLogger=e.createLogger,exports.createNoOpLogger=e.createNoOpLogger,exports.creditCard=e.creditCard,exports.cuid=e.cuid,exports.cuid2=e.cuid2,exports.custom=e.custom,exports.date=e.date,exports.decode=e.decode,exports.decodeAsync=e.decodeAsync,exports.deepPartial=e.deepPartial,exports.default=e.default,exports.describe=e.describe,exports.disableLogging=e.disableLogging,exports.discriminatedUnion=e.discriminatedUnion,exports.e164=e.e164,exports.email=e.email,exports.emoji=e.emoji,exports.enableDebug=e.enableDebug,exports.encode=e.encode,exports.encodeAsync=e.encodeAsync,exports.endsWith=e.endsWith,exports.enum=e.enum,exports.exactOptional=e.exactOptional,exports.file=e.file,exports.float32=e.float32,exports.float64=e.float64,exports.formatError=e.formatError,exports.fromJSONSchema=e.fromJSONSchema,exports.function=e._function,exports.getErrorMap=e.getErrorMap,exports.getLogger=e.getLogger,exports.gt=e.gt,exports.gte=e.gte,exports.guid=e.guid,exports.hash=e.hash,exports.hex=e.hex,exports.hexBytes=e.hexBytes,exports.hostname=e.hostname,exports.httpUrl=e.httpUrl,exports.includes=e.includes,exports.initLogger=e.initLogger,exports.input=e.input,exports.instanceof=e.instanceof,exports.int=e.int,exports.int32=e.int32,exports.int64=e.int64,exports.intersection=e.intersection,exports.ipv4=e.ipv4,exports.ipv6=e.ipv6,exports.iso=e.iso,exports.json=e.json,exports.jwt=e.jwt,exports.keyof=e.keyof,exports.ksuid=e.ksuid,exports.lazy=e.lazy,exports.length=e.length,exports.literal=e.literal,exports.locales=e.locales,exports.looseObject=e.looseObject,exports.looseRecord=e.looseRecord,exports.lowercase=e.lowercase,exports.lt=e.lt,exports.lte=e.lte,exports.mac=e.mac,exports.map=e.map,exports.mapSchema=e.mapSchema,exports.maxLength=e.maxLength,exports.maxSize=e.maxSize,exports.meta=e.meta,exports.mime=e.mime,exports.minLength=e.minLength,exports.minSize=e.minSize,exports.multipleOf=e.multipleOf,exports.nan=e.nan,exports.nanoid=e.nanoid,exports.nativeEnum=e.nativeEnum,exports.negative=e.negative,exports.never=e.never,exports.nonnegative=e.nonnegative,exports.nonoptional=e.nonoptional,exports.nonpositive=e.nonpositive,exports.normalize=e.normalize,exports.null=e.null,exports.nullable=e.nullable,exports.nullish=e.nullish,exports.number=e.number,exports.object=e.object,exports.optional=e.optional,exports.output=e.output,exports.overwrite=e.overwrite,exports.parse=e.parse,exports.parseAsync=e.parseAsync,exports.partialRecord=e.partialRecord,exports.pipe=e.pipe,exports.positive=e.positive,exports.prefault=e.prefault,exports.preprocess=e.preprocess,exports.promise=e.promise,exports.property=e.property,exports.readonly=e.readonly,exports.record=e.record,exports.refine=e.refine,exports.regex=e.regex,exports.regexes=e.regexes,exports.safeDecode=e.safeDecode,exports.safeDecodeAsync=e.safeDecodeAsync,exports.safeEncode=e.safeEncode,exports.safeEncodeAsync=e.safeEncodeAsync,exports.safeParse=e.safeParse,exports.safeParseAsync=e.safeParseAsync,exports.set=e.set,exports.setErrorMap=e.setErrorMap,exports.setLogLevel=e.setLogLevel,exports.size=e.size,exports.slugify=e.slugify,exports.startsWith=e.startsWith,exports.strictObject=e.strictObject,exports.string=e.string,exports.stringFormat=e.stringFormat,exports.stringbool=e.stringbool,exports.superRefine=e.superRefine,exports.symbol=e.symbol,exports.templateLiteral=e.templateLiteral,exports.toJSONSchema=e.toJSONSchema,exports.toLowerCase=e.toLowerCase,exports.toUpperCase=e.toUpperCase,exports.toZodError=e.toZodError,exports.toZodSafeResult=e.toZodSafeResult,exports.transform=e.transform,exports.trim=e.trim,exports.tuple=e.tuple,exports.uint32=e.uint32,exports.uint64=e.uint64,exports.uint8Array=e.uint8Array,exports.ulid=e.ulid,exports.undefined=e.undefined,exports.union=e.union,exports.unknown=e.unknown,exports.uppercase=e.uppercase,exports.url=e.url,exports.util=e.util,exports.uuid=e.uuid,exports.uuidv4=e.uuidv4,exports.uuidv6=e.uuidv6,exports.uuidv7=e.uuidv7,exports.v=e.default,exports.vV2=e.vV2,exports.void=e.void,exports.xid=e.xid,exports.xor=e.xor,exports.z=e.z,exports.ZodCompileAsyncError=r.ZodCompileAsyncError,exports.ZodCompileError=r.ZodCompileError,exports.ZodCompileUnsupportedError=r.ZodCompileUnsupportedError,exports.compile=r.compile,exports.getDiscriminatedOption=r.getDiscriminatedOption,exports.memoizer=r.memoizer,exports.properties=r.properties,exports.toZod=r.toZod,exports.validate=r.validate,exports.validateAsync=r.validateAsync,exports.zodCompileFn=r.compileFn,exports.Err=o.Err,exports.Ok=o.Ok,exports.ResultUtils=o.ResultUtils,exports.all=o.all,exports.failure=o.failure,exports.flatMap=o.flatMap,exports.fromNullable=o.fromNullable,exports.isErr=o.isErr,exports.isOk=o.isOk,exports.isResult=o.isResult,exports.mapErr=o.mapErr,exports.match=o.match,exports.success=o.success,exports.tryCatch=o.tryCatch,exports.tryCatchAsync=o.tryCatchAsync,exports.unwrap=o.unwrap,exports.unwrapOr=o.unwrapOr,exports.VldBase=t.VldBase,exports.VldMeta=t.VldMeta,exports.ZodBranded=t.VldBrand,exports.ZodCatch=t.VldCatch,exports.ZodDefault=t.VldDefault,exports.ZodExactOptional=t.VldExactOptional,exports.ZodMeta=t.VldMeta,exports.ZodMiniBrand=t.VldBrand,exports.ZodMiniCatch=t.VldCatch,exports.ZodMiniDefault=t.VldDefault,exports.ZodMiniExactOptional=t.VldExactOptional,exports.ZodMiniNonOptional=t.VldRefine,exports.ZodMiniNullable=t.VldNullable,exports.ZodMiniOptional=t.VldOptional,exports.ZodMiniPipe=t.VldPipe,exports.ZodMiniPrefault=t.VldPrefault,exports.ZodMiniReadonly=t.VldReadonly,exports.ZodMiniTransform=t.VldTransform,exports.ZodMiniType=t.VldBase,exports.ZodNonOptional=t.VldRefine,exports.ZodNullable=t.VldNullable,exports.ZodOptional=t.VldOptional,exports.ZodPipe=t.VldPipe,exports.ZodPrefault=t.VldPrefault,exports.ZodPreprocess=t.VldPreprocess,exports.ZodReadonly=t.VldReadonly,exports.ZodTransform=t.VldTransform,exports.ZodType=t.VldBase,exports.VldError=s.VldError,exports.ZodError=s.VldError,exports.ZodRealError=s.VldError,exports.VldIntersection=i.VldIntersection,exports.ZodIntersection=i.VldIntersection,exports.ZodMiniIntersection=i.VldIntersection,exports.ZodAny=p.VldAny,exports.ZodMiniAny=p.VldAny,exports.ZodArray=a.VldArray,exports.ZodMiniArray=a.VldArray,exports.ZodBase64=n.VldStringFormat,exports.ZodBase64URL=n.VldStringFormat,exports.ZodCIDRv4=n.VldStringFormat,exports.ZodCIDRv6=n.VldStringFormat,exports.ZodCUID=n.VldStringFormat,exports.ZodCUID2=n.VldStringFormat,exports.ZodCreditCard=n.VldStringFormat,exports.ZodCustomStringFormat=n.VldStringFormat,exports.ZodE164=n.VldStringFormat,exports.ZodEmail=n.VldStringFormat,exports.ZodEmoji=n.VldStringFormat,exports.ZodGUID=n.VldStringFormat,exports.ZodIPv4=n.VldStringFormat,exports.ZodIPv6=n.VldStringFormat,exports.ZodISODate=n.VldStringFormat,exports.ZodISODateTime=n.VldStringFormat,exports.ZodISODuration=n.VldStringFormat,exports.ZodISOTime=n.VldStringFormat,exports.ZodJWT=n.VldStringFormat,exports.ZodKSUID=n.VldStringFormat,exports.ZodMAC=n.VldStringFormat,exports.ZodMiniBase64=n.VldStringFormat,exports.ZodMiniBase64URL=n.VldStringFormat,exports.ZodMiniCIDRv4=n.VldStringFormat,exports.ZodMiniCIDRv6=n.VldStringFormat,exports.ZodMiniCUID=n.VldStringFormat,exports.ZodMiniCUID2=n.VldStringFormat,exports.ZodMiniCreditCard=n.VldStringFormat,exports.ZodMiniCustomStringFormat=n.VldStringFormat,exports.ZodMiniE164=n.VldStringFormat,exports.ZodMiniEmail=n.VldStringFormat,exports.ZodMiniEmoji=n.VldStringFormat,exports.ZodMiniGUID=n.VldStringFormat,exports.ZodMiniIPv4=n.VldStringFormat,exports.ZodMiniIPv6=n.VldStringFormat,exports.ZodMiniISODate=n.VldStringFormat,exports.ZodMiniISODateTime=n.VldStringFormat,exports.ZodMiniISODuration=n.VldStringFormat,exports.ZodMiniISOTime=n.VldStringFormat,exports.ZodMiniJWT=n.VldStringFormat,exports.ZodMiniKSUID=n.VldStringFormat,exports.ZodMiniMAC=n.VldStringFormat,exports.ZodMiniNanoID=n.VldStringFormat,exports.ZodMiniStringFormat=n.VldStringFormat,exports.ZodMiniULID=n.VldStringFormat,exports.ZodMiniURL=n.VldStringFormat,exports.ZodMiniUUID=n.VldStringFormat,exports.ZodMiniXID=n.VldStringFormat,exports.ZodNanoID=n.VldStringFormat,exports.ZodStringFormat=n.VldStringFormat,exports.ZodULID=n.VldStringFormat,exports.ZodURL=n.VldStringFormat,exports.ZodUUID=n.VldStringFormat,exports.ZodXID=n.VldStringFormat,exports.ZodBigInt=l.VldBigInt,exports.ZodBigIntFormat=l.VldBigInt,exports.ZodMiniBigInt=l.VldBigInt,exports.ZodMiniBigIntFormat=l.VldBigInt,exports.ZodBoolean=d.VldBoolean,exports.ZodMiniBoolean=d.VldBoolean,exports.ZodCodec=x.VldCodec,exports.ZodMiniCodec=x.VldCodec,exports.ZodCustom=c.VldCustom,exports.ZodMiniCustom=c.VldCustom,exports.ZodMiniSuccess=c.VldCustom,exports.ZodSuccess=c.VldCustom,exports.ZodDate=u.VldDate,exports.ZodMiniDate=u.VldDate,exports.ZodDiscriminatedUnion=m.VldDiscriminatedUnion,exports.ZodMiniDiscriminatedUnion=m.VldDiscriminatedUnion,exports.ZodEnum=g.VldEnum,exports.ZodMiniEnum=g.VldEnum,exports.ZodFile=V.VldFile,exports.ZodMiniFile=V.VldFile,exports.ZodFunction=Z.VldFunction,exports.ZodMiniFunction=Z.VldFunction,exports.ZodJSON=y.VldJson,exports.ZodLazy=j.VldLazy,exports.ZodMiniLazy=j.VldLazy,exports.ZodLiteral=v.VldLiteral,exports.ZodMiniLiteral=v.VldLiteral,exports.ZodMap=f.VldMap,exports.ZodMiniMap=f.VldMap,exports.ZodMiniNaN=S.VldNan,exports.ZodNaN=S.VldNan,exports.ZodMiniNever=q.VldNever,exports.ZodNever=q.VldNever,exports.ZodMiniNull=M.VldNull,exports.ZodNull=M.VldNull,exports.ZodMiniNumber=b.VldNumber,exports.ZodMiniNumberFormat=b.VldNumber,exports.ZodNumber=b.VldNumber,exports.ZodNumberFormat=b.VldNumber,exports.ZodMiniObject=F.VldObject,exports.ZodObject=F.VldObject,exports.ZodMiniPromise=T.VldPromise,exports.ZodPromise=T.VldPromise,exports.ZodMiniRecord=h.VldRecord,exports.ZodRecord=h.VldRecord,exports.ZodMiniSet=E.VldSet,exports.ZodSet=E.VldSet,exports.ZodMiniString=L.VldString,exports.ZodString=L.VldString,exports.ZodMiniSymbol=U.VldSymbol,exports.ZodSymbol=U.VldSymbol,exports.ZodMiniTemplateLiteral=C.VldTemplateLiteral,exports.ZodTemplateLiteral=C.VldTemplateLiteral,exports.ZodMiniTuple=D.VldTuple,exports.ZodTuple=D.VldTuple,exports.ZodMiniUndefined=I.VldUndefined,exports.ZodUndefined=I.VldUndefined,exports.ZodMiniUnion=B.VldUnion,exports.ZodUnion=B.VldUnion,exports.ZodMiniUnknown=O.VldUnknown,exports.ZodUnknown=O.VldUnknown,exports.ZodMiniVoid=A.VldVoid,exports.ZodVoid=A.VldVoid,exports.ZodMiniXor=N.VldXor,exports.ZodXor=N.VldXor,exports.base64Json=R.base64Json,exports.base64ToBytes=R.base64ToBytes,exports.base64ToUint8Array=R.base64ToUint8Array,exports.base64UrlToBytes=R.base64UrlToBytes,exports.base64urlToBytes=R.base64urlToBytes,exports.bytesToUtf8=R.bytesToUtf8,exports.epochMillisToDate=R.epochMillisToDate,exports.epochSecondsToDate=R.epochSecondsToDate,exports.hexLowerToBytes=R.hexLowerToBytes,exports.hexToBytes=R.hexToBytes,exports.hexToUint8Array=R.hexToUint8Array,exports.invertCodec=R.invertCodec,exports.isoDatetimeToDate=R.isoDatetimeToDate,exports.jsonCodec=R.jsonCodec,exports.jwtPayload=R.jwtPayload,exports.numberToBigInt=R.numberToBigInt,exports.stringToBigInt=R.stringToBigInt,exports.stringToBoolean=R.stringToBoolean,exports.stringToHttpURL=R.stringToHttpURL,exports.stringToInt=R.stringToInt,exports.stringToNumber=R.stringToNumber,exports.stringToURL=R.stringToURL,exports.stringToUint8Array=R.stringToUint8Array,exports.uint8ArrayToBase64=R.uint8ArrayToBase64,exports.uint8ArrayToBase64Url=R.uint8ArrayToBase64Url,exports.uint8ArrayToHex=R.uint8ArrayToHex,exports.uint8ArrayToString=R.uint8ArrayToString,exports.uriComponent=R.uriComponent,exports.utf8ToBytes=R.utf8ToBytes,exports.blue=P.blue,exports.bold=P.bold,exports.createTheme=P.createTheme,exports.cyan=P.cyan,exports.dim=P.dim,exports.gray=P.gray,exports.green=P.green,exports.grey=P.grey,exports.italic=P.italic,exports.magenta=P.magenta,exports.pigment=P.default,exports.red=P.red,exports.strip=P.strip,exports.supportsColor=P.supportsColor,exports.underline=P.underline,exports.vldTheme=P.vldTheme,exports.white=P.white,exports.yellow=P.yellow,exports.createEmitter=k.createEmitter,exports.createEventBus=k.createEventBus,exports.withEmitter=k.withEmitter,exports.createVldKernel=w.createVldKernel,exports.definePlugin=w.definePlugin,exports.getVldKernel=w.getVldKernel,exports.resetVldKernel=w.resetVldKernel,exports.usePlugin=w.usePlugin,exports.flattenError=z.flattenError,exports.prettifyError=z.prettifyError,exports.prettifyErrorColored=z.prettifyErrorColored,exports.prettifyErrorPlain=z.prettifyErrorPlain,exports.treeifyError=z.treeifyError,exports.getLocale=J.getLocale,exports.getMessages=J.getMessages,exports.getSupportedLocales=J.getSupportedLocales,exports.isLocaleLoaded=J.isLocaleLoaded,exports.isLocaleSupported=J.isLocaleSupported,exports.registerLocale=J.registerLocale,exports.setLocale=J.setLocale,exports.globalRegistry=K.globalRegistry,exports.registry=K.registry,exports.setLocaleAsync=_.setLocaleAsync,exports._default=(e,r)=>e.default("function"==typeof r?r():r),exports.catchall=(e,r)=>e.catchall(r),exports.exactPartial=e=>e.exactPartial(),exports.extend=(e,r)=>e.extend(r),exports.maximum=(r,o)=>{const t=W(o);return e.number().max(r,t)},exports.merge=(e,r)=>r&&"function"==typeof r.parse?e.merge(r):e.extend(r),exports.minimum=(r,o)=>{const t=W(o);return e.number().min(r,t)},exports.omit=(e,r)=>e.omit(...X(r)),exports.partial=e=>e.partial(),exports.pick=(e,r)=>e.pick(...X(r)),exports.required=e=>e.required(),exports.safeExtend=(e,r)=>e.safeExtend(r);
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../index.cjs"),r=require("../compile.cjs"),o=require("../compat/result.cjs"),t=require("../validators/base.cjs"),s=require("../chunks/errors-core-C0mA6tfa.cjs"),i=require("../validators/intersection.cjs"),p=require("../validators/any.cjs"),a=require("../validators/array.cjs"),n=require("../validators/string-formats.cjs"),d=require("../validators/bigint.cjs"),l=require("../validators/boolean.cjs"),x=require("../validators/codec.cjs"),c=require("../validators/custom.cjs"),u=require("../validators/date.cjs"),m=require("../validators/discriminated-union.cjs"),g=require("../validators/enum.cjs"),V=require("../validators/file.cjs"),Z=require("../validators/function.cjs"),y=require("../validators/json.cjs"),j=require("../validators/lazy.cjs"),v=require("../validators/literal.cjs"),f=require("../validators/map.cjs"),S=require("../validators/nan.cjs"),M=require("../validators/never.cjs"),q=require("../validators/null.cjs"),b=require("../validators/number.cjs"),F=require("../validators/object.cjs"),T=require("../validators/promise.cjs"),h=require("../validators/record.cjs"),E=require("../validators/set.cjs"),I=require("../validators/string.cjs"),L=require("../validators/symbol.cjs"),C=require("../validators/template-literal.cjs"),U=require("../validators/tuple.cjs"),D=require("../validators/undefined.cjs"),B=require("../validators/union.cjs"),A=require("../validators/unknown.cjs"),N=require("../validators/void.cjs"),O=require("../validators/xor.cjs"),P=require("../chunks/index-ZjHAxYdA.cjs"),R=require("../pigment.cjs"),w=require("../compat/emitter.cjs"),k=require("../kernel.cjs"),z=require("../errors.cjs"),_=require("../locales/runtime.cjs"),J=require("../registry.cjs"),K=require("../chunks/index-DJwZFerZ.cjs");function X(e){return Object.keys(e).filter(r=>e[r])}function W(e){return"string"==typeof e?e:e?.message||e?.error}require("../validators/string-v2.cjs"),require("../chunks/ip-validation-BZqPamPC.cjs"),require("../locales/en.cjs"),require("../validators/number-v2.cjs"),require("../validators/date-v2.cjs"),require("../validators/bigint-v2.cjs"),require("../validators/array-v2.cjs"),require("../validators/union-v2.cjs"),require("../validators/wrapper-v2.cjs"),require("../validators/leaf-v2.cjs"),require("../validators/composite-v2.cjs"),require("../validators/string-bool.cjs"),require("../validators/base64.cjs"),require("../validators/hex.cjs"),require("../validators/uint8array.cjs"),require("../coercion/index.cjs"),require("../chunks/security-aXZVI7qW.cjs"),require("../locales/tr.cjs"),require("../locales/es.cjs"),require("../locales/fr.cjs"),require("../locales/de.cjs"),require("../locales/it.cjs"),require("../locales/pt.cjs"),require("../locales/ru.cjs"),require("../locales/ja.cjs"),require("../locales/ko.cjs"),require("../locales/zh.cjs"),require("../locales/ar.cjs"),require("../locales/hi.cjs"),require("../locales/nl.cjs"),require("../locales/pl.cjs"),require("../locales/da.cjs"),require("../locales/sv.cjs"),require("../locales/no.cjs"),require("../locales/fi.cjs"),require("../locales/th.cjs"),require("../locales/vi.cjs"),require("../locales/id.cjs"),require("../locales/bn.cjs"),require("../locales/gu.cjs"),require("../locales/kn.cjs"),require("../locales/ne.cjs"),require("../locales/sk.cjs"),require("../locales/tg.cjs"),require("../locales/sw.cjs"),require("../locales/af.cjs"),require("../locales/pt-BR.cjs"),require("../locales/es-MX.cjs");exports.$brand=e.$brand,exports.$input=e.$input,exports.$output=e.$output,exports.NEVER=e.NEVER,exports.TimePrecision=e.TimePrecision,exports.ZodFirstPartyTypeKind=e.ZodFirstPartyTypeKind,exports.ZodIssueCode=e.ZodIssueCode,exports.ZodLikeError=e.ZodLikeError,exports._ZodString=e._ZodString,exports._function=e._function,exports.any=e.any,exports.array=e.array,exports.base64=e.base64,exports.base64Bytes=e.base64Bytes,exports.base64url=e.base64url,exports.bigint=e.bigint,exports.boolean=e.boolean,exports.catch=e.catch,exports.check=e.check,exports.cidrv4=e.cidrv4,exports.cidrv6=e.cidrv6,exports.clone=e.clone,exports.codec=e.codec,exports.coerce=e.coerce,exports.config=e.config,exports.core=e.core,exports.createLogger=e.createLogger,exports.createNoOpLogger=e.createNoOpLogger,exports.creditCard=e.creditCard,exports.cuid=e.cuid,exports.cuid2=e.cuid2,exports.currencyCode=e.currencyCode,exports.custom=e.custom,exports.date=e.date,exports.decode=e.decode,exports.decodeAsync=e.decodeAsync,exports.deepPartial=e.deepPartial,exports.default=e.default,exports.describe=e.describe,exports.disableLogging=e.disableLogging,exports.discriminatedUnion=e.discriminatedUnion,exports.e164=e.e164,exports.email=e.email,exports.emoji=e.emoji,exports.enableDebug=e.enableDebug,exports.encode=e.encode,exports.encodeAsync=e.encodeAsync,exports.endsWith=e.endsWith,exports.enum=e.enum,exports.exactOptional=e.exactOptional,exports.file=e.file,exports.float32=e.float32,exports.float64=e.float64,exports.formatError=e.formatError,exports.fromJSONSchema=e.fromJSONSchema,exports.function=e._function,exports.getErrorMap=e.getErrorMap,exports.getLogger=e.getLogger,exports.gt=e.gt,exports.gte=e.gte,exports.guid=e.guid,exports.hash=e.hash,exports.hex=e.hex,exports.hexBytes=e.hexBytes,exports.hostname=e.hostname,exports.httpUrl=e.httpUrl,exports.iban=e.iban,exports.includes=e.includes,exports.initLogger=e.initLogger,exports.input=e.input,exports.instanceof=e.instanceof,exports.int=e.int,exports.int32=e.int32,exports.int64=e.int64,exports.intersection=e.intersection,exports.ipv4=e.ipv4,exports.ipv6=e.ipv6,exports.iso=e.iso,exports.json=e.json,exports.jwt=e.jwt,exports.keyof=e.keyof,exports.ksuid=e.ksuid,exports.lazy=e.lazy,exports.length=e.length,exports.literal=e.literal,exports.locales=e.locales,exports.looseObject=e.looseObject,exports.looseRecord=e.looseRecord,exports.lowercase=e.lowercase,exports.lt=e.lt,exports.lte=e.lte,exports.mac=e.mac,exports.map=e.map,exports.mapSchema=e.mapSchema,exports.maxLength=e.maxLength,exports.maxSize=e.maxSize,exports.meta=e.meta,exports.mime=e.mime,exports.minLength=e.minLength,exports.minSize=e.minSize,exports.multipleOf=e.multipleOf,exports.nan=e.nan,exports.nanoid=e.nanoid,exports.nativeEnum=e.nativeEnum,exports.negative=e.negative,exports.never=e.never,exports.nonnegative=e.nonnegative,exports.nonoptional=e.nonoptional,exports.nonpositive=e.nonpositive,exports.normalize=e.normalize,exports.null=e.null,exports.nullable=e.nullable,exports.nullish=e.nullish,exports.number=e.number,exports.object=e.object,exports.optional=e.optional,exports.output=e.output,exports.overwrite=e.overwrite,exports.parse=e.parse,exports.parseAsync=e.parseAsync,exports.partialRecord=e.partialRecord,exports.pipe=e.pipe,exports.positive=e.positive,exports.prefault=e.prefault,exports.preprocess=e.preprocess,exports.promise=e.promise,exports.property=e.property,exports.readonly=e.readonly,exports.record=e.record,exports.refine=e.refine,exports.regex=e.regex,exports.regexes=e.regexes,exports.safeDecode=e.safeDecode,exports.safeDecodeAsync=e.safeDecodeAsync,exports.safeEncode=e.safeEncode,exports.safeEncodeAsync=e.safeEncodeAsync,exports.safeParse=e.safeParse,exports.safeParseAsync=e.safeParseAsync,exports.set=e.set,exports.setErrorMap=e.setErrorMap,exports.setLogLevel=e.setLogLevel,exports.size=e.size,exports.slugify=e.slugify,exports.startsWith=e.startsWith,exports.strictObject=e.strictObject,exports.string=e.string,exports.stringFormat=e.stringFormat,exports.stringbool=e.stringbool,exports.superRefine=e.superRefine,exports.symbol=e.symbol,exports.templateLiteral=e.templateLiteral,exports.toJSONSchema=e.toJSONSchema,exports.toLowerCase=e.toLowerCase,exports.toUpperCase=e.toUpperCase,exports.toZodError=e.toZodError,exports.toZodSafeResult=e.toZodSafeResult,exports.transform=e.transform,exports.trim=e.trim,exports.tuple=e.tuple,exports.uint32=e.uint32,exports.uint64=e.uint64,exports.uint8Array=e.uint8Array,exports.ulid=e.ulid,exports.undefined=e.undefined,exports.union=e.union,exports.unknown=e.unknown,exports.uppercase=e.uppercase,exports.url=e.url,exports.util=e.util,exports.uuid=e.uuid,exports.uuidv4=e.uuidv4,exports.uuidv6=e.uuidv6,exports.uuidv7=e.uuidv7,exports.v=e.default,exports.vV2=e.vV2,exports.void=e.void,exports.xid=e.xid,exports.xor=e.xor,exports.z=e.z,exports.COMPILE_INVALID=r.COMPILE_INVALID,exports.INVALID=r.COMPILE_INVALID,exports.ZodCompileAsyncError=r.ZodCompileAsyncError,exports.ZodCompileError=r.ZodCompileError,exports.ZodCompileUnsupportedError=r.ZodCompileUnsupportedError,exports.compile=r.compile,exports.getDiscriminatedOption=r.getDiscriminatedOption,exports.memoizer=r.memoizer,exports.properties=r.properties,exports.toZod=r.toZod,exports.validate=r.validate,exports.validateAsync=r.validateAsync,exports.withParser=r.withParser,exports.zodCompileFn=r.compileFn,exports.Err=o.Err,exports.Ok=o.Ok,exports.ResultUtils=o.ResultUtils,exports.all=o.all,exports.failure=o.failure,exports.flatMap=o.flatMap,exports.fromNullable=o.fromNullable,exports.isErr=o.isErr,exports.isOk=o.isOk,exports.isResult=o.isResult,exports.mapErr=o.mapErr,exports.match=o.match,exports.success=o.success,exports.tryCatch=o.tryCatch,exports.tryCatchAsync=o.tryCatchAsync,exports.unwrap=o.unwrap,exports.unwrapOr=o.unwrapOr,exports.VldBase=t.VldBase,exports.VldMeta=t.VldMeta,exports.ZodBranded=t.VldBrand,exports.ZodCatch=t.VldCatch,exports.ZodDefault=t.VldDefault,exports.ZodExactOptional=t.VldExactOptional,exports.ZodMeta=t.VldMeta,exports.ZodMiniBrand=t.VldBrand,exports.ZodMiniCatch=t.VldCatch,exports.ZodMiniDefault=t.VldDefault,exports.ZodMiniExactOptional=t.VldExactOptional,exports.ZodMiniNonOptional=t.VldRefine,exports.ZodMiniNullable=t.VldNullable,exports.ZodMiniOptional=t.VldOptional,exports.ZodMiniPipe=t.VldPipe,exports.ZodMiniPrefault=t.VldPrefault,exports.ZodMiniReadonly=t.VldReadonly,exports.ZodMiniTransform=t.VldTransform,exports.ZodMiniType=t.VldBase,exports.ZodNonOptional=t.VldRefine,exports.ZodNullable=t.VldNullable,exports.ZodOptional=t.VldOptional,exports.ZodPipe=t.VldPipe,exports.ZodPrefault=t.VldPrefault,exports.ZodPreprocess=t.VldPreprocess,exports.ZodReadonly=t.VldReadonly,exports.ZodTransform=t.VldTransform,exports.ZodType=t.VldBase,exports.VldError=s.VldError,exports.ZodError=s.VldError,exports.ZodRealError=s.VldError,exports.VldIntersection=i.VldIntersection,exports.ZodIntersection=i.VldIntersection,exports.ZodMiniIntersection=i.VldIntersection,exports.ZodAny=p.VldAny,exports.ZodMiniAny=p.VldAny,exports.ZodArray=a.VldArray,exports.ZodMiniArray=a.VldArray,exports.ZodBase64=n.VldStringFormat,exports.ZodBase64URL=n.VldStringFormat,exports.ZodCIDRv4=n.VldStringFormat,exports.ZodCIDRv6=n.VldStringFormat,exports.ZodCUID=n.VldStringFormat,exports.ZodCUID2=n.VldStringFormat,exports.ZodCreditCard=n.VldStringFormat,exports.ZodCustomStringFormat=n.VldStringFormat,exports.ZodE164=n.VldStringFormat,exports.ZodEmail=n.VldStringFormat,exports.ZodEmoji=n.VldStringFormat,exports.ZodGUID=n.VldStringFormat,exports.ZodIBAN=n.VldStringFormat,exports.ZodIPv4=n.VldStringFormat,exports.ZodIPv6=n.VldStringFormat,exports.ZodISODate=n.VldStringFormat,exports.ZodISODateTime=n.VldStringFormat,exports.ZodISODuration=n.VldStringFormat,exports.ZodISOTime=n.VldStringFormat,exports.ZodJWT=n.VldStringFormat,exports.ZodKSUID=n.VldStringFormat,exports.ZodMAC=n.VldStringFormat,exports.ZodMiniBase64=n.VldStringFormat,exports.ZodMiniBase64URL=n.VldStringFormat,exports.ZodMiniCIDRv4=n.VldStringFormat,exports.ZodMiniCIDRv6=n.VldStringFormat,exports.ZodMiniCUID=n.VldStringFormat,exports.ZodMiniCUID2=n.VldStringFormat,exports.ZodMiniCreditCard=n.VldStringFormat,exports.ZodMiniCustomStringFormat=n.VldStringFormat,exports.ZodMiniE164=n.VldStringFormat,exports.ZodMiniEmail=n.VldStringFormat,exports.ZodMiniEmoji=n.VldStringFormat,exports.ZodMiniGUID=n.VldStringFormat,exports.ZodMiniIBAN=n.VldStringFormat,exports.ZodMiniIPv4=n.VldStringFormat,exports.ZodMiniIPv6=n.VldStringFormat,exports.ZodMiniISODate=n.VldStringFormat,exports.ZodMiniISODateTime=n.VldStringFormat,exports.ZodMiniISODuration=n.VldStringFormat,exports.ZodMiniISOTime=n.VldStringFormat,exports.ZodMiniJWT=n.VldStringFormat,exports.ZodMiniKSUID=n.VldStringFormat,exports.ZodMiniMAC=n.VldStringFormat,exports.ZodMiniNanoID=n.VldStringFormat,exports.ZodMiniStringFormat=n.VldStringFormat,exports.ZodMiniULID=n.VldStringFormat,exports.ZodMiniURL=n.VldStringFormat,exports.ZodMiniUUID=n.VldStringFormat,exports.ZodMiniXID=n.VldStringFormat,exports.ZodNanoID=n.VldStringFormat,exports.ZodStringFormat=n.VldStringFormat,exports.ZodULID=n.VldStringFormat,exports.ZodURL=n.VldStringFormat,exports.ZodUUID=n.VldStringFormat,exports.ZodXID=n.VldStringFormat,exports.isValidIBAN=n.isValidIBAN,exports.ZodBigInt=d.VldBigInt,exports.ZodBigIntFormat=d.VldBigInt,exports.ZodMiniBigInt=d.VldBigInt,exports.ZodMiniBigIntFormat=d.VldBigInt,exports.ZodBoolean=l.VldBoolean,exports.ZodMiniBoolean=l.VldBoolean,exports.ZodCodec=x.VldCodec,exports.ZodMiniCodec=x.VldCodec,exports.ZodCustom=c.VldCustom,exports.ZodInstanceOf=c.VldInstance,exports.ZodMiniCustom=c.VldCustom,exports.ZodMiniSuccess=c.VldCustom,exports.ZodSuccess=c.VldCustom,exports.ZodDate=u.VldDate,exports.ZodMiniDate=u.VldDate,exports.ZodDiscriminatedUnion=m.VldDiscriminatedUnion,exports.ZodMiniDiscriminatedUnion=m.VldDiscriminatedUnion,exports.ZodEnum=g.VldEnum,exports.ZodMiniEnum=g.VldEnum,exports.ZodFile=V.VldFile,exports.ZodMiniFile=V.VldFile,exports.ZodFunction=Z.VldFunction,exports.ZodMiniFunction=Z.VldFunction,exports.ZodJSON=y.VldJson,exports.ZodLazy=j.VldLazy,exports.ZodMiniLazy=j.VldLazy,exports.ZodLiteral=v.VldLiteral,exports.ZodMiniLiteral=v.VldLiteral,exports.ZodMap=f.VldMap,exports.ZodMiniMap=f.VldMap,exports.ZodMiniNaN=S.VldNan,exports.ZodNaN=S.VldNan,exports.ZodMiniNever=M.VldNever,exports.ZodNever=M.VldNever,exports.ZodMiniNull=q.VldNull,exports.ZodNull=q.VldNull,exports.ZodMiniNumber=b.VldNumber,exports.ZodMiniNumberFormat=b.VldNumber,exports.ZodNumber=b.VldNumber,exports.ZodNumberFormat=b.VldNumber,exports.ZodMiniObject=F.VldObject,exports.ZodObject=F.VldObject,exports.ZodMiniPromise=T.VldPromise,exports.ZodPromise=T.VldPromise,exports.ZodMiniRecord=h.VldRecord,exports.ZodRecord=h.VldRecord,exports.ZodMiniSet=E.VldSet,exports.ZodSet=E.VldSet,exports.ZodMiniString=I.VldString,exports.ZodString=I.VldString,exports.ZodMiniSymbol=L.VldSymbol,exports.ZodSymbol=L.VldSymbol,exports.ZodMiniTemplateLiteral=C.VldTemplateLiteral,exports.ZodTemplateLiteral=C.VldTemplateLiteral,exports.ZodMiniTuple=U.VldTuple,exports.ZodTuple=U.VldTuple,exports.ZodMiniUndefined=D.VldUndefined,exports.ZodUndefined=D.VldUndefined,exports.ZodMiniUnion=B.VldUnion,exports.ZodUnion=B.VldUnion,exports.ZodMiniUnknown=A.VldUnknown,exports.ZodUnknown=A.VldUnknown,exports.ZodMiniVoid=N.VldVoid,exports.ZodVoid=N.VldVoid,exports.ZodMiniXor=O.VldXor,exports.ZodXor=O.VldXor,exports.base64Json=P.base64Json,exports.base64ToBytes=P.base64ToBytes,exports.base64ToUint8Array=P.base64ToUint8Array,exports.base64UrlToBytes=P.base64UrlToBytes,exports.base64urlToBytes=P.base64urlToBytes,exports.bytesToUtf8=P.bytesToUtf8,exports.epochMillisToDate=P.epochMillisToDate,exports.epochSecondsToDate=P.epochSecondsToDate,exports.hexLowerToBytes=P.hexLowerToBytes,exports.hexToBytes=P.hexToBytes,exports.hexToUint8Array=P.hexToUint8Array,exports.invertCodec=P.invertCodec,exports.isoDatetimeToDate=P.isoDatetimeToDate,exports.jsonCodec=P.jsonCodec,exports.jwtPayload=P.jwtPayload,exports.numberToBigInt=P.numberToBigInt,exports.stringToBigInt=P.stringToBigInt,exports.stringToBoolean=P.stringToBoolean,exports.stringToHttpURL=P.stringToHttpURL,exports.stringToInt=P.stringToInt,exports.stringToNumber=P.stringToNumber,exports.stringToURL=P.stringToURL,exports.stringToUint8Array=P.stringToUint8Array,exports.uint8ArrayToBase64=P.uint8ArrayToBase64,exports.uint8ArrayToBase64Url=P.uint8ArrayToBase64Url,exports.uint8ArrayToHex=P.uint8ArrayToHex,exports.uint8ArrayToString=P.uint8ArrayToString,exports.uriComponent=P.uriComponent,exports.utf8ToBytes=P.utf8ToBytes,exports.blue=R.blue,exports.bold=R.bold,exports.createTheme=R.createTheme,exports.cyan=R.cyan,exports.dim=R.dim,exports.gray=R.gray,exports.green=R.green,exports.grey=R.grey,exports.italic=R.italic,exports.magenta=R.magenta,exports.pigment=R.default,exports.red=R.red,exports.strip=R.strip,exports.supportsColor=R.supportsColor,exports.underline=R.underline,exports.vldTheme=R.vldTheme,exports.white=R.white,exports.yellow=R.yellow,exports.createEmitter=w.createEmitter,exports.createEventBus=w.createEventBus,exports.withEmitter=w.withEmitter,exports.createVldKernel=k.createVldKernel,exports.definePlugin=k.definePlugin,exports.getVldKernel=k.getVldKernel,exports.resetVldKernel=k.resetVldKernel,exports.usePlugin=k.usePlugin,exports.flattenError=z.flattenError,exports.prettifyError=z.prettifyError,exports.prettifyErrorColored=z.prettifyErrorColored,exports.prettifyErrorPlain=z.prettifyErrorPlain,exports.treeifyError=z.treeifyError,exports.getLocale=_.getLocale,exports.getMessages=_.getMessages,exports.getSupportedLocales=_.getSupportedLocales,exports.isLocaleLoaded=_.isLocaleLoaded,exports.isLocaleSupported=_.isLocaleSupported,exports.registerLocale=_.registerLocale,exports.setLocale=_.setLocale,exports.globalRegistry=J.globalRegistry,exports.registry=J.registry,exports.setLocaleAsync=K.setLocaleAsync,exports._default=(e,r)=>e.default("function"==typeof r?r():r),exports.catchall=(e,r)=>e.catchall(r),exports.exactPartial=e=>e.exactPartial(),exports.extend=(e,r)=>e.extend(r),exports.maximum=(r,o)=>{const t=W(o);return e.number().max(r,t)},exports.merge=(e,r)=>r&&"function"==typeof r.parse?e.merge(r):e.extend(r),exports.minimum=(r,o)=>{const t=W(o);return e.number().min(r,t)},exports.omit=(e,r)=>e.omit(...X(r)),exports.partial=e=>e.partial(),exports.pick=(e,r)=>e.pick(...X(r)),exports.required=e=>e.required(),exports.safeExtend=(e,r)=>e.safeExtend(r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("../registry.cjs"),t=require("../chunks/errors-core-C0mA6tfa.cjs");function s(e){if(e instanceof t.VldError)return e;const s=e instanceof Error?e.message:String(e);return new t.VldError([{code:"custom",path:[],message:s}])}const r={STRING:"string",STRING_FORMAT:"stringFormat",STRING_BOOL:"stringBool",NUMBER:"number",BOOLEAN:"boolean",DATE:"date",BIGINT:"bigint",UNDEFINED:"undefined",NULL:"null",UNKNOWN:"unknown",ANY:"any",VOID:"void",NEVER:"never",SYMBOL:"symbol",NAN:"nan",HEX:"hex",BASE64:"base64",UINT8_ARRAY:"uint8Array",COERCE_STRING:"coerceString",COERCE_NUMBER:"coerceNumber",COERCE_BOOLEAN:"coerceBoolean",COERCE_DATE:"coerceDate",COERCE_BIGINT:"coerceBigint",OBJECT:"object",ARRAY:"array",TUPLE:"tuple",SET:"set",MAP:"map",RECORD:"record",UNION:"union",DISCRIMINATED_UNION:"discriminatedUnion",INTERSECTION:"intersection",XOR:"xor",ENUM:"enum",LITERAL:"literal",LAZY:"lazy",CUSTOM:"custom",FUNCTION:"function",FILE:"file",JSON:"json",TEMPLATE_LITERAL:"templateLiteral",PROMISE:"promise",OPTIONAL:"optional",NULLABLE:"nullable",NULLISH:"nullish",EXACT_OPTIONAL:"exactOptional",DEFAULT:"default",CATCH:"catch",REFINE:"refine",TRANSFORM:"transform",PIPE:"pipe",PREPROCESS:"preprocess",SUPER_REFINE:"superRefine",BRAND:"brand",READONLY:"readonly",META:"meta",PREFAULT:"prefault",PREFault:"prefault",CODEC:"codec"};function a(e,t){if("string"==typeof e)return e;if("function"==typeof e){const s=e(void 0);return"string"==typeof s?s:"object"==typeof s&&s?.message?s.message:t}if("object"==typeof e&&null!==e){if("string"==typeof e.error)return e.error;if("function"==typeof e.error)return e.error({})||t;if("string"==typeof e.message)return e.message}return t}function i(e){return null!==e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}let n;function o(e){return"function"==typeof e?e():function(e){if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(null!==e&&"object"==typeof e){const t=Object.getPrototypeOf(e);if(t===Object.prototype||null===t)return{...e}}return e}(e)}function h(e){if(!0===e.isSimple)switch(e.validatorType){case r.STRING:return"string";case r.NUMBER:return"number";case r.BOOLEAN:return"boolean";case r.BIGINT:return"bigint";case r.SYMBOL:return"symbol";default:return}}function l(e,t){switch(e){case"string":return"string"==typeof t?t:void 0;case"number":return"number"!=typeof t||isNaN(t)?void 0:t;case"boolean":return"boolean"==typeof t?t:void 0;case"bigint":return"bigint"==typeof t?t:void 0;case"symbol":return"symbol"==typeof t?t:void 0;default:return}}class VldBase{constructor(e="unknown"){this.validatorType=e}get type(){return this.validatorType}get _def(){return{typeName:"Zod"+this.validatorType.charAt(0).toUpperCase()+this.validatorType.slice(1),...this.config||{}}}get def(){return this._def}get _zod(){return this._def}get"~standard"(){return{version:1,vendor:"vld",validate:e=>{const t=this.safeParse(e);return t.success?{value:t.data}:{issues:[{message:t.error.message}]}},types:void 0}}async parseAsync(e){return this.parse(e)}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}decode(e){return this.parse(e)}safeDecode(e){return this.safeParse(e)}async decodeAsync(e){return this.parseAsync(e)}async safeDecodeAsync(e){return this.safeParseAsync(e)}encode(e){return this.parse(e)}safeEncode(e){const t=this.safeParse(e);return t.success?{success:!0,data:t.data}:t}async encodeAsync(e){return this.parseAsync(e)}async safeEncodeAsync(e){const t=await this.safeParseAsync(e);return t.success?{success:!0,data:t.data}:t}spa(e){return this.safeParseAsync(e)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}clone(){return this}isValid(e){return this.safeParse(e).success}parseOrDefault(e,t){const s=this.safeParse(e);if(s.success)return s.data;const r=this.safeParse(t);if(!r.success)throw new Error(`Invalid default value provided: ${r.error.message}`);return r.data}refine(e,t){return new VldRefine(this,e,t)}superRefine(e){return new VldSuperRefine(this,e)}transform(e){return new VldTransform(this,e)}default(e){return new VldDefault(this,e)}prefault(e){return new VldPrefault(this,e)}nonoptional(e){return new VldRefine(this,e=>void 0!==e,a(e,"Expected non-optional value"))}array(){return n.array(this)}or(e){return n.union(this,e)}and(e){return n.intersection(this,e)}overwrite(e){return new VldTransform(this,e)}with(...e){return new VldSuperRefine(this,(t,s)=>{const r={value:t,issues:[]},a=[];for(const t of e){const e="function"==typeof t?t:t._zod?.check;if(!e)continue;const s=e(r);i(s)&&a.push(Promise.resolve(s))}const n=()=>{for(const e of r.issues)s.addIssue(void 0===e.code?{message:e.message||"Custom check failed"}:{message:e.message||"Custom check failed",code:e.code})};if(a.length>0)return Promise.all(a).then(n);n()})}toJSONSchema(e){return n.toJSONSchema(this,e)}catch(e){return new VldCatch(this,e)}optional(){return new VldOptional(this)}nullable(){return new VldNullable(this)}nullish(){return new VldNullish(this)}exactOptional(){return new VldExactOptional(this)}pipe(e){return new VldPipe(this,e)}readonly(){return new VldReadonly(this)}brand(){return new VldBrand(this)}apply(e){return e(this)}check(e,t){return this.refine(e,t)}meta(t){if(void 0===t)return e.globalRegistry.get(this)??this.baseValidator?.meta?.()??this.schema?.meta?.()??this.inner?.meta?.();const s=new VldMeta(this,t);return e.globalRegistry.add(s,t),s}register(e,t){return e.add(this,t),this}describe(e){return this.meta({description:e})}get description(){return this.meta()?.description??this.baseValidator?.description??this.schema?.description??this.inner?.description}}class VldMeta extends VldBase{constructor(e,t){super(r.META),this.baseValidator=e,this.metadata=t}parse(e){return this.baseValidator.parse(e)}safeParse(e){return this.baseValidator.safeParse(e)}getMeta(){return{...this.metadata}}meta(t){if(void 0===t)return{...this.metadata,...e.globalRegistry.get(this)};const s=new VldMeta(this.baseValidator,{...this.metadata,...t});return e.globalRegistry.add(s,s.getMeta()),s}describe(e){return this.meta({description:e})}}class VldReadonly extends VldBase{constructor(e){super(r.READONLY),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const t=this.baseValidator.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,error:t.error}}}class VldBrand extends VldBase{constructor(e){super(r.BRAND),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const t=this.baseValidator.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,error:t.error}}}class VldRefine extends VldBase{constructor(e,t,s){super(r.REFINE),this.baseValidator=e,this.predicate=t,this.customMessage=s??"Refinement check failed","object"==typeof s&&null!==s&&"path"in s&&Array.isArray(s.path)&&(this.refinePath=s.path)}_createIssue(e){if("function"==typeof this.customMessage){const t=this.customMessage(e);return"string"==typeof t?{code:"custom",path:this.refinePath??[],message:t}:{code:"custom",path:t?.path??this.refinePath??[],message:t?.message??"Refinement check failed"}}if("object"==typeof this.customMessage&&null!==this.customMessage){const e=this.customMessage.message??this.customMessage.error,t="function"==typeof e?e({}):"string"==typeof e?e:"Refinement check failed";return{code:"custom",path:this.customMessage.path??this.refinePath??[],message:t}}return{code:"custom",path:this.refinePath??[],message:"string"==typeof this.customMessage?this.customMessage:"Refinement check failed"}}parse(e){const s=this.baseValidator.parse(e),r=this.predicate(s);if(i(r))throw new Error("Use parseAsync for async refinements");if(!r)throw new t.VldError([this._createIssue(s)]);return s}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:s(e)}}}async parseAsync(e){const s=await this.baseValidator.parseAsync(e);if(!await this.predicate(s))throw new t.VldError([this._createIssue(s)]);return s}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}_wrap(e){return new VldRefine(e,this.predicate,this.customMessage)}min(e,t){return this._wrap(this.baseValidator.min?.(e,t)??this.baseValidator)}max(e,t){return this._wrap(this.baseValidator.max?.(e,t)??this.baseValidator)}length(e,t){return this._wrap(this.baseValidator.length?.(e,t)??this.baseValidator)}email(e){return this._wrap(this.baseValidator.email?.(e)??this.baseValidator)}url(e){return this._wrap(this.baseValidator.url?.(e)??this.baseValidator)}uuid(e){return this._wrap(this.baseValidator.uuid?.(e)??this.baseValidator)}regex(e,t){return this._wrap(this.baseValidator.regex?.(e,t)??this.baseValidator)}startsWith(e,t){return this._wrap(this.baseValidator.startsWith?.(e,t)??this.baseValidator)}endsWith(e,t){return this._wrap(this.baseValidator.endsWith?.(e,t)??this.baseValidator)}includes(e,t){return this._wrap(this.baseValidator.includes?.(e,t)??this.baseValidator)}ip(e){return this._wrap(this.baseValidator.ip?.(e)??this.baseValidator)}ipv4(e){return this._wrap(this.baseValidator.ipv4?.(e)??this.baseValidator)}ipv6(e){return this._wrap(this.baseValidator.ipv6?.(e)??this.baseValidator)}nonempty(e){return this._wrap(this.baseValidator.nonempty?.(e)??this.baseValidator)}trim(){return this._wrap(this.baseValidator.trim?.()??this.baseValidator)}toLowerCase(){return this._wrap(this.baseValidator.toLowerCase?.()??this.baseValidator)}lowercase(){return this.toLowerCase()}toUpperCase(){return this._wrap(this.baseValidator.toUpperCase?.()??this.baseValidator)}uppercase(){return this.toUpperCase()}positive(e){return this._wrap(this.baseValidator.positive?.(e)??this.baseValidator)}negative(e){return this._wrap(this.baseValidator.negative?.(e)??this.baseValidator)}nonnegative(e){return this._wrap(this.baseValidator.nonnegative?.(e)??this.baseValidator)}nonpositive(e){return this._wrap(this.baseValidator.nonpositive?.(e)??this.baseValidator)}int(e){return this._wrap(this.baseValidator.int?.(e)??this.baseValidator)}finite(e){return this._wrap(this.baseValidator.finite?.(e)??this.baseValidator)}safe(e){return this._wrap(this.baseValidator.safe?.(e)??this.baseValidator)}multipleOf(e,t){return this._wrap(this.baseValidator.multipleOf?.(e,t)??this.baseValidator)}step(e,t){return this._wrap(this.baseValidator.step?.(e,t)??this.baseValidator)}gt(e,t){return this._wrap(this.baseValidator.gt?.(e,t)??this.baseValidator)}gte(e,t){return this._wrap(this.baseValidator.gte?.(e,t)??this.baseValidator)}lt(e,t){return this._wrap(this.baseValidator.lt?.(e,t)??this.baseValidator)}lte(e,t){return this._wrap(this.baseValidator.lte?.(e,t)??this.baseValidator)}extend(e){return this._wrap(this.baseValidator.extend?.(e)??this.baseValidator)}merge(e){return this._wrap(this.baseValidator.merge?.(e)??this.baseValidator)}pick(...e){return this._wrap(this.baseValidator.pick?.(...e)??this.baseValidator)}omit(...e){return this._wrap(this.baseValidator.omit?.(...e)??this.baseValidator)}partial(){return this._wrap(this.baseValidator.partial?.()??this.baseValidator)}required(){return this._wrap(this.baseValidator.required?.()??this.baseValidator)}strict(e){return this._wrap(this.baseValidator.strict?.(e)??this.baseValidator)}passthrough(){return this._wrap(this.baseValidator.passthrough?.()??this.baseValidator)}strip(){return this._wrap(this.baseValidator.strip?.()??this.baseValidator)}catchall(e){return this._wrap(this.baseValidator.catchall?.(e)??this.baseValidator)}get shape(){return this.baseValidator.shape}get keyof(){return this.baseValidator.keyof}unwrap(){return this.baseValidator.unwrap?this.baseValidator.unwrap():this.baseValidator}get element(){return this.baseValidator.element}}class VldTransform extends VldBase{constructor(e,t){super(r.TRANSFORM),this.baseValidator=e,this.transformer=t}parse(e){const t=this.baseValidator.parse(e);try{const e=this.transformer(t);if(i(e))throw new Error("Use parseAsync for async transforms");return e}catch(e){throw new Error(`Transform failed: ${e.message}`)}}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:s(e)}}}async parseAsync(e){const t=await this.baseValidator.parseAsync(e);try{return await this.transformer(t)}catch(e){throw new Error(`Transform failed: ${e.message}`)}}}class VldDefault extends VldBase{constructor(e,t){super(r.DEFAULT),this.baseValidator=e,this.defaultValue=t}parse(e){return void 0===e?o(this.defaultValue):this.baseValidator.parse(e)}safeParse(e){return void 0===e?{success:!0,data:o(this.defaultValue)}:this.baseValidator.safeParse(e)}prefault(e){return new VldPrefault(this.baseValidator,void 0===e?this.defaultValue:e)}unwrap(){return this.baseValidator}removeDefault(){return this.baseValidator}}class VldPrefault extends VldBase{constructor(e,t){super(r.PREFAULT),this.baseValidator=e,this.defaultValue=t}parse(e){return void 0===e?this.baseValidator.parse(o(this.defaultValue)):this.baseValidator.parse(e)}safeParse(e){return void 0===e?this.baseValidator.safeParse(o(this.defaultValue)):this.baseValidator.safeParse(e)}prefault(e){return void 0===e?this:new VldPrefault(this.baseValidator,e)}unwrap(){return this.baseValidator}}class VldCatch extends VldBase{constructor(e,t){super(r.CATCH),this.baseValidator=e,this.fallbackValue=t,this.simpleMode=h(e);const s=e.safeParse(t);if(!s.success)throw new Error(`Invalid fallback value: ${s.error.message}`)}parse(e){const t=l(this.simpleMode,e);if(void 0!==t)return t;if(void 0!==this.simpleMode)return this.fallbackValue;try{return this.baseValidator.parse(e)}catch{return this.fallbackValue}}safeParse(e){const t=l(this.simpleMode,e);if(void 0!==t)return{success:!0,data:t};if(void 0!==this.simpleMode)return{success:!0,data:this.fallbackValue};const s=this.baseValidator.safeParse(e);return s.success?s:{success:!0,data:this.fallbackValue}}}class VldOptional extends VldBase{constructor(e){super(r.OPTIONAL),this.baseValidator=e,this.simpleMode=h(e)}parseSimpleValue(e){return l(this.simpleMode,e)}static create(e){return new VldOptional(e)}parse(e){if(void 0===e)return;const t=this.parseSimpleValue(e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const t=this.parseSimpleValue(e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldExactOptional extends VldBase{constructor(e){super(r.EXACT_OPTIONAL),this.baseValidator=e,this.simpleMode=h(e)}static create(e){return new VldExactOptional(e)}parse(e){if(void 0===e)return;const t=l(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const t=l(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullable extends VldBase{constructor(e){super(r.NULLABLE),this.baseValidator=e,this.simpleMode=h(e)}static create(e){return new VldNullable(e)}parse(e){if(null===e)return null;const t=l(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(null===e)return{success:!0,data:null};const t=l(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullish extends VldBase{constructor(e){super(r.NULLISH),this.baseValidator=e,this.simpleMode=h(e)}static create(e){return new VldNullish(e)}parse(e){if(null==e)return e;const t=l(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(null==e)return{success:!0,data:e};const t=l(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldPipe extends VldBase{constructor(e,t){super(r.PIPE),this.first=e,this.second=t}parse(e){const t=this.first.parse(e);return this.second.parse(t)}safeParse(e){const t=this.first.safeParse(e);return t.success?this.second.safeParse(t.data):{success:!1,error:t.error}}}class VldSuperRefine extends VldBase{constructor(e,t){super(r.SUPER_REFINE),this._inner=e,this._refinement=t}parse(e){const s=this._inner.parse(e),r=[],a={addIssue:e=>{r.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(this._refinement(s,a)instanceof Promise)throw new Error("Use parseAsync for async refinements");if(r.length>0)throw new t.VldError(r,r.map(e=>e.message).join("; "));return s}safeParse(e){const r=this._inner.safeParse(e);if(!r.success)return{success:!1,error:s(r.error)};const a=[],i={addIssue:e=>{a.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(this._refinement(r.data,i)instanceof Promise)throw new Error("Use safeParseAsync for async refinements");return a.length>0?{success:!1,error:new t.VldError(a,a.map(e=>e.message).join("; "))}:r}async parseAsync(e){const s=await this._inner.parseAsync(e),r=[],a={addIssue:e=>{r.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(await this._refinement(s,a),r.length>0)throw new t.VldError(r,r.map(e=>e.message).join("; "));return s}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}_wrap(e){return new VldSuperRefine(e,this._refinement)}min(e,t){return this._wrap(this._inner.min?.(e,t)??this._inner)}max(e,t){return this._wrap(this._inner.max?.(e,t)??this._inner)}length(e,t){return this._wrap(this._inner.length?.(e,t)??this._inner)}email(e){return this._wrap(this._inner.email?.(e)??this._inner)}url(e){return this._wrap(this._inner.url?.(e)??this._inner)}uuid(e){return this._wrap(this._inner.uuid?.(e)??this._inner)}regex(e,t){return this._wrap(this._inner.regex?.(e,t)??this._inner)}startsWith(e,t){return this._wrap(this._inner.startsWith?.(e,t)??this._inner)}endsWith(e,t){return this._wrap(this._inner.endsWith?.(e,t)??this._inner)}includes(e,t){return this._wrap(this._inner.includes?.(e,t)??this._inner)}ip(e){return this._wrap(this._inner.ip?.(e)??this._inner)}ipv4(e){return this._wrap(this._inner.ipv4?.(e)??this._inner)}ipv6(e){return this._wrap(this._inner.ipv6?.(e)??this._inner)}nonempty(e){return this._wrap(this._inner.nonempty?.(e)??this._inner)}trim(){return this._wrap(this._inner.trim?.()??this._inner)}toLowerCase(){return this._wrap(this._inner.toLowerCase?.()??this._inner)}lowercase(){return this.toLowerCase()}toUpperCase(){return this._wrap(this._inner.toUpperCase?.()??this._inner)}uppercase(){return this.toUpperCase()}positive(e){return this._wrap(this._inner.positive?.(e)??this._inner)}negative(e){return this._wrap(this._inner.negative?.(e)??this._inner)}nonnegative(e){return this._wrap(this._inner.nonnegative?.(e)??this._inner)}nonpositive(e){return this._wrap(this._inner.nonpositive?.(e)??this._inner)}int(e){return this._wrap(this._inner.int?.(e)??this._inner)}finite(e){return this._wrap(this._inner.finite?.(e)??this._inner)}safe(e){return this._wrap(this._inner.safe?.(e)??this._inner)}multipleOf(e,t){return this._wrap(this._inner.multipleOf?.(e,t)??this._inner)}step(e,t){return this._wrap(this._inner.step?.(e,t)??this._inner)}gt(e,t){return this._wrap(this._inner.gt?.(e,t)??this._inner)}gte(e,t){return this._wrap(this._inner.gte?.(e,t)??this._inner)}lt(e,t){return this._wrap(this._inner.lt?.(e,t)??this._inner)}lte(e,t){return this._wrap(this._inner.lte?.(e,t)??this._inner)}extend(e){return this._wrap(this._inner.extend?.(e)??this._inner)}merge(e){return this._wrap(this._inner.merge?.(e)??this._inner)}pick(...e){return this._wrap(this._inner.pick?.(...e)??this._inner)}omit(...e){return this._wrap(this._inner.omit?.(...e)??this._inner)}partial(){return this._wrap(this._inner.partial?.()??this._inner)}required(){return this._wrap(this._inner.required?.()??this._inner)}strict(e){return this._wrap(this._inner.strict?.(e)??this._inner)}passthrough(){return this._wrap(this._inner.passthrough?.()??this._inner)}strip(){return this._wrap(this._inner.strip?.()??this._inner)}catchall(e){return this._wrap(this._inner.catchall?.(e)??this._inner)}get shape(){return this._inner.shape}get keyof(){return this._inner.keyof}unwrap(){return this._inner.unwrap?this._inner.unwrap():this._inner}get element(){return this._inner.element}}class VldPreprocess extends VldBase{constructor(e,t){super(r.PREPROCESS),this._preprocessor=e,this._schema=t}static create(e,t){return new VldPreprocess(e,t)}parse(e){const t=this._preprocessor(e);return this._schema.parse(t)}safeParse(e){try{const t=this._preprocessor(e);return this._schema.safeParse(t)}catch(e){return{success:!1,error:s(e)}}}}exports.VLD_VALIDATOR_TYPES=r,exports.VldBase=VldBase,exports.VldBrand=VldBrand,exports.VldCatch=VldCatch,exports.VldDefault=VldDefault,exports.VldExactOptional=VldExactOptional,exports.VldMeta=VldMeta,exports.VldNullable=VldNullable,exports.VldNullish=VldNullish,exports.VldOptional=VldOptional,exports.VldPipe=VldPipe,exports.VldPrefault=VldPrefault,exports.VldPreprocess=VldPreprocess,exports.VldReadonly=VldReadonly,exports.VldRefine=VldRefine,exports.VldSuperRefine=VldSuperRefine,exports.VldTransform=VldTransform,exports.configureSchemaCompositionFactories=function(e){n=e},exports.ensureVldError=s,exports.isPromiseLike=i,exports.resolveErrorMessage=a;
|
|
1
|
+
"use strict";var e=require("../registry.cjs"),t=require("../chunks/errors-core-C0mA6tfa.cjs");function s(e){if(e instanceof t.VldError)return e;const s=e instanceof Error?e.message:String(e);return new t.VldError([{code:"custom",path:[],message:s}])}const r=Symbol.for("@oxog/vld/compile-invalid");function a(e){let t=null;try{const s=globalThis?.["@oxog/vld/lazy-validate-compiler"];t=(s?s(e):null)??null}catch{t=null}return Object.defineProperty(e,"__vldValidateFn",{value:t,enumerable:!1,configurable:!0}),t}const i={STRING:"string",STRING_FORMAT:"stringFormat",STRING_BOOL:"stringBool",NUMBER:"number",BOOLEAN:"boolean",DATE:"date",BIGINT:"bigint",UNDEFINED:"undefined",NULL:"null",UNKNOWN:"unknown",ANY:"any",VOID:"void",NEVER:"never",SYMBOL:"symbol",NAN:"nan",HEX:"hex",BASE64:"base64",UINT8_ARRAY:"uint8Array",COERCE_STRING:"coerceString",COERCE_NUMBER:"coerceNumber",COERCE_BOOLEAN:"coerceBoolean",COERCE_DATE:"coerceDate",COERCE_BIGINT:"coerceBigint",OBJECT:"object",ARRAY:"array",TUPLE:"tuple",SET:"set",MAP:"map",RECORD:"record",UNION:"union",DISCRIMINATED_UNION:"discriminatedUnion",INTERSECTION:"intersection",XOR:"xor",ENUM:"enum",LITERAL:"literal",LAZY:"lazy",CUSTOM:"custom",FUNCTION:"function",FILE:"file",JSON:"json",TEMPLATE_LITERAL:"templateLiteral",PROMISE:"promise",OPTIONAL:"optional",NULLABLE:"nullable",NULLISH:"nullish",EXACT_OPTIONAL:"exactOptional",DEFAULT:"default",CATCH:"catch",REFINE:"refine",TRANSFORM:"transform",PIPE:"pipe",PREPROCESS:"preprocess",SUPER_REFINE:"superRefine",BRAND:"brand",READONLY:"readonly",META:"meta",PREFAULT:"prefault",PREFault:"prefault",CODEC:"codec"};function n(e,t){if("string"==typeof e)return e;if("function"==typeof e){const s=e(void 0);return"string"==typeof s?s:"object"==typeof s&&s?.message?s.message:t}if("object"==typeof e&&null!==e){if("string"==typeof e.error)return e.error;if("function"==typeof e.error)return e.error({})||t;if("string"==typeof e.message)return e.message}return t}function o(e){return null!==e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}let l;function h(e){return"function"==typeof e?e():function(e){if(Array.isArray(e))return[...e];if(e instanceof Map)return new Map(e);if(e instanceof Set)return new Set(e);if(null!==e&&"object"==typeof e){const t=Object.getPrototypeOf(e);if(t===Object.prototype||null===t)return{...e}}return e}(e)}function u(e){if(!0===e.isSimple)switch(e.validatorType){case i.STRING:return"string";case i.NUMBER:return"number";case i.BOOLEAN:return"boolean";case i.BIGINT:return"bigint";case i.SYMBOL:return"symbol";default:return}}function d(e,t){switch(e){case"string":return"string"==typeof t?t:void 0;case"number":return"number"!=typeof t||isNaN(t)?void 0:t;case"boolean":return"boolean"==typeof t?t:void 0;case"bigint":return"bigint"==typeof t?t:void 0;case"symbol":return"symbol"==typeof t?t:void 0;default:return}}class VldBase{constructor(e="unknown"){this.validatorType=e}get type(){return this.validatorType}get _def(){return{typeName:"Zod"+this.validatorType.charAt(0).toUpperCase()+this.validatorType.slice(1),...this.config||{}}}get def(){return this._def}get _zod(){return this._def}get"~standard"(){return{version:1,vendor:"vld",validate:e=>{const t=this.safeParse(e);return t.success?{value:t.data}:{issues:[{message:t.error.message}]}},types:void 0}}async parseAsync(e){return this.parse(e)}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}decode(e){return this.parse(e)}safeDecode(e){return this.safeParse(e)}async decodeAsync(e){return this.parseAsync(e)}async safeDecodeAsync(e){return this.safeParseAsync(e)}encode(e){return this.parse(e)}safeEncode(e){const t=this.safeParse(e);return t.success?{success:!0,data:t.data}:t}async encodeAsync(e){return this.parseAsync(e)}async safeEncodeAsync(e){const t=await this.safeParseAsync(e);return t.success?{success:!0,data:t.data}:t}spa(e){return this.safeParseAsync(e)}validate(e){const t=this.__vldValidateFn;return void 0!==t?null!==t?t(e)!==r:this.validateWithRuntimeParser(e):this.initValidate(e)}validateWithRuntimeParser(e){let t=this.__vldSafeFn;return void 0===t&&(t=this.__vldSafeFn=this.safeParse.bind(this)),Boolean(t(e).success)}initValidate(e){const t=this,s=t._zod?.bag,i=s?.validatorValidate??s?.validator;if(void 0!==i)return Object.defineProperty(t,"__vldValidateFn",{value:i,enumerable:!1,configurable:!0}),i(e)!==r;const n=a(t);return null!==n?n(e)!==r:this.validateWithRuntimeParser(e)}async validateAsync(e){const t=this.__vldValidateFn;if(null!=t)return t(e)!==r;if(void 0===t){this.initValidate(e);const t=this.__vldValidateFn;if(null!=t)return t(e)!==r}return(await this.safeParseAsync(e)).success}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}clone(){return this}isValid(e){return this.validate(e)}parseOrDefault(e,t){const s=this.safeParse(e);if(s.success)return s.data;const r=this.safeParse(t);if(!r.success)throw new Error(`Invalid default value provided: ${r.error.message}`);return r.data}refine(e,t){return new VldRefine(this,e,t)}superRefine(e){return new VldSuperRefine(this,e)}transform(e){return new VldTransform(this,e)}default(e){return new VldDefault(this,e)}prefault(e){return new VldPrefault(this,e)}nonoptional(e){return new VldRefine(this,e=>void 0!==e,n(e,"Expected non-optional value"))}array(){return l.array(this)}or(e){return l.union(this,e)}and(e){return l.intersection(this,e)}overwrite(e){return new VldTransform(this,e)}with(...e){return new VldSuperRefine(this,(t,s)=>{const r={value:t,issues:[]},a=[];for(const t of e){const e="function"==typeof t?t:t._zod?.check;if(!e)continue;const s=e(r);o(s)&&a.push(Promise.resolve(s))}const i=()=>{for(const e of r.issues)s.addIssue(void 0===e.code?{message:e.message||"Custom check failed"}:{message:e.message||"Custom check failed",code:e.code})};if(a.length>0)return Promise.all(a).then(i);i()})}toJSONSchema(e){return l.toJSONSchema(this,e)}catch(e){return new VldCatch(this,e)}optional(){return new VldOptional(this)}nullable(){return new VldNullable(this)}nullish(){return new VldNullish(this)}exactOptional(){return new VldExactOptional(this)}pipe(e){return new VldPipe(this,e)}readonly(){return new VldReadonly(this)}brand(){return new VldBrand(this)}apply(e){return e(this)}check(e,t){return this.refine(e,t)}meta(t){if(void 0===t)return e.globalRegistry.get(this)??this.baseValidator?.meta?.()??this.schema?.meta?.()??this.inner?.meta?.();const s=new VldMeta(this,t);return e.globalRegistry.add(s,t),s}register(e,t){return e.add(this,t),this}describe(e){return this.meta({description:e})}get description(){return this.meta()?.description??this.baseValidator?.description??this.schema?.description??this.inner?.description}}class VldMeta extends VldBase{constructor(e,t){super(i.META),this.baseValidator=e,this.metadata=t}parse(e){return this.baseValidator.parse(e)}safeParse(e){return this.baseValidator.safeParse(e)}getMeta(){return{...this.metadata}}meta(t){if(void 0===t)return{...this.metadata,...e.globalRegistry.get(this)};const s=new VldMeta(this.baseValidator,{...this.metadata,...t});return e.globalRegistry.add(s,s.getMeta()),s}describe(e){return this.meta({description:e})}}class VldReadonly extends VldBase{constructor(e){super(i.READONLY),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const t=this.baseValidator.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,error:t.error}}}class VldBrand extends VldBase{constructor(e){super(i.BRAND),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const t=this.baseValidator.safeParse(e);return t.success?{success:!0,data:t.data}:{success:!1,error:t.error}}}class VldRefine extends VldBase{constructor(e,t,s){super(i.REFINE),this.baseValidator=e,this.predicate=t,this.customMessage=s??"Refinement check failed","object"==typeof s&&null!==s&&"path"in s&&Array.isArray(s.path)&&(this.refinePath=s.path)}_createIssue(e){if("function"==typeof this.customMessage){const t=this.customMessage(e);return"string"==typeof t?{code:"custom",path:this.refinePath??[],message:t}:{code:"custom",path:t?.path??this.refinePath??[],message:t?.message??"Refinement check failed"}}if("object"==typeof this.customMessage&&null!==this.customMessage){const e=this.customMessage.message??this.customMessage.error,t="function"==typeof e?e({}):"string"==typeof e?e:"Refinement check failed";return{code:"custom",path:this.customMessage.path??this.refinePath??[],message:t}}return{code:"custom",path:this.refinePath??[],message:"string"==typeof this.customMessage?this.customMessage:"Refinement check failed"}}parse(e){const s=this.baseValidator.parse(e),r=this.predicate(s);if(o(r))throw new Error("Use parseAsync for async refinements");if(!r)throw new t.VldError([this._createIssue(s)]);return s}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:s(e)}}}async parseAsync(e){const s=await this.baseValidator.parseAsync(e);if(!await this.predicate(s))throw new t.VldError([this._createIssue(s)]);return s}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}_wrap(e){return new VldRefine(e,this.predicate,this.customMessage)}min(e,t){return this._wrap(this.baseValidator.min?.(e,t)??this.baseValidator)}max(e,t){return this._wrap(this.baseValidator.max?.(e,t)??this.baseValidator)}length(e,t){return this._wrap(this.baseValidator.length?.(e,t)??this.baseValidator)}email(e){return this._wrap(this.baseValidator.email?.(e)??this.baseValidator)}url(e){return this._wrap(this.baseValidator.url?.(e)??this.baseValidator)}uuid(e){return this._wrap(this.baseValidator.uuid?.(e)??this.baseValidator)}regex(e,t){return this._wrap(this.baseValidator.regex?.(e,t)??this.baseValidator)}startsWith(e,t){return this._wrap(this.baseValidator.startsWith?.(e,t)??this.baseValidator)}endsWith(e,t){return this._wrap(this.baseValidator.endsWith?.(e,t)??this.baseValidator)}includes(e,t){return this._wrap(this.baseValidator.includes?.(e,t)??this.baseValidator)}ip(e){return this._wrap(this.baseValidator.ip?.(e)??this.baseValidator)}ipv4(e){return this._wrap(this.baseValidator.ipv4?.(e)??this.baseValidator)}ipv6(e){return this._wrap(this.baseValidator.ipv6?.(e)??this.baseValidator)}nonempty(e){return this._wrap(this.baseValidator.nonempty?.(e)??this.baseValidator)}trim(){return this._wrap(this.baseValidator.trim?.()??this.baseValidator)}toLowerCase(){return this._wrap(this.baseValidator.toLowerCase?.()??this.baseValidator)}lowercase(){return this.toLowerCase()}toUpperCase(){return this._wrap(this.baseValidator.toUpperCase?.()??this.baseValidator)}uppercase(){return this.toUpperCase()}positive(e){return this._wrap(this.baseValidator.positive?.(e)??this.baseValidator)}negative(e){return this._wrap(this.baseValidator.negative?.(e)??this.baseValidator)}nonnegative(e){return this._wrap(this.baseValidator.nonnegative?.(e)??this.baseValidator)}nonpositive(e){return this._wrap(this.baseValidator.nonpositive?.(e)??this.baseValidator)}int(e){return this._wrap(this.baseValidator.int?.(e)??this.baseValidator)}finite(e){return this._wrap(this.baseValidator.finite?.(e)??this.baseValidator)}safe(e){return this._wrap(this.baseValidator.safe?.(e)??this.baseValidator)}multipleOf(e,t){return this._wrap(this.baseValidator.multipleOf?.(e,t)??this.baseValidator)}step(e,t){return this._wrap(this.baseValidator.step?.(e,t)??this.baseValidator)}gt(e,t){return this._wrap(this.baseValidator.gt?.(e,t)??this.baseValidator)}gte(e,t){return this._wrap(this.baseValidator.gte?.(e,t)??this.baseValidator)}lt(e,t){return this._wrap(this.baseValidator.lt?.(e,t)??this.baseValidator)}lte(e,t){return this._wrap(this.baseValidator.lte?.(e,t)??this.baseValidator)}extend(e){return this._wrap(this.baseValidator.extend?.(e)??this.baseValidator)}merge(e){return this._wrap(this.baseValidator.merge?.(e)??this.baseValidator)}pick(...e){return this._wrap(this.baseValidator.pick?.(...e)??this.baseValidator)}omit(...e){return this._wrap(this.baseValidator.omit?.(...e)??this.baseValidator)}partial(){return this._wrap(this.baseValidator.partial?.()??this.baseValidator)}required(){return this._wrap(this.baseValidator.required?.()??this.baseValidator)}strict(e){return this._wrap(this.baseValidator.strict?.(e)??this.baseValidator)}passthrough(){return this._wrap(this.baseValidator.passthrough?.()??this.baseValidator)}strip(){return this._wrap(this.baseValidator.strip?.()??this.baseValidator)}catchall(e){return this._wrap(this.baseValidator.catchall?.(e)??this.baseValidator)}get shape(){return this.baseValidator.shape}get keyof(){return this.baseValidator.keyof}unwrap(){return this.baseValidator.unwrap?this.baseValidator.unwrap():this.baseValidator}get element(){return this.baseValidator.element}}class VldTransform extends VldBase{constructor(e,t){super(i.TRANSFORM),this.baseValidator=e,this.transformer=t}parse(e){const t=this.baseValidator.parse(e);try{const e=this.transformer(t);if(o(e))throw new Error("Use parseAsync for async transforms");return e}catch(e){throw new Error(`Transform failed: ${e.message}`)}}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:s(e)}}}async parseAsync(e){const t=await this.baseValidator.parseAsync(e);try{return await this.transformer(t)}catch(e){throw new Error(`Transform failed: ${e.message}`)}}}class VldDefault extends VldBase{constructor(e,t){super(i.DEFAULT),this.baseValidator=e,this.defaultValue=t}parse(e){return void 0===e?h(this.defaultValue):this.baseValidator.parse(e)}safeParse(e){return void 0===e?{success:!0,data:h(this.defaultValue)}:this.baseValidator.safeParse(e)}prefault(e){return new VldPrefault(this.baseValidator,void 0===e?this.defaultValue:e)}unwrap(){return this.baseValidator}removeDefault(){return this.baseValidator}}class VldPrefault extends VldBase{constructor(e,t){super(i.PREFAULT),this.baseValidator=e,this.defaultValue=t}parse(e){return void 0===e?this.baseValidator.parse(h(this.defaultValue)):this.baseValidator.parse(e)}safeParse(e){return void 0===e?this.baseValidator.safeParse(h(this.defaultValue)):this.baseValidator.safeParse(e)}prefault(e){return void 0===e?this:new VldPrefault(this.baseValidator,e)}unwrap(){return this.baseValidator}}class VldCatch extends VldBase{constructor(e,t){super(i.CATCH),this.baseValidator=e,this.fallbackValue=t,this.simpleMode=u(e);const s=e.safeParse(t);if(!s.success)throw new Error(`Invalid fallback value: ${s.error.message}`)}parse(e){const t=d(this.simpleMode,e);if(void 0!==t)return t;if(void 0!==this.simpleMode)return this.fallbackValue;try{return this.baseValidator.parse(e)}catch{return this.fallbackValue}}safeParse(e){const t=d(this.simpleMode,e);if(void 0!==t)return{success:!0,data:t};if(void 0!==this.simpleMode)return{success:!0,data:this.fallbackValue};const s=this.baseValidator.safeParse(e);return s.success?s:{success:!0,data:this.fallbackValue}}}class VldOptional extends VldBase{constructor(e){super(i.OPTIONAL),this.baseValidator=e,this.simpleMode=u(e)}parseSimpleValue(e){return d(this.simpleMode,e)}static create(e){return new VldOptional(e)}parse(e){if(void 0===e)return;const t=this.parseSimpleValue(e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const t=this.parseSimpleValue(e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldExactOptional extends VldBase{constructor(e){super(i.EXACT_OPTIONAL),this.baseValidator=e,this.simpleMode=u(e)}static create(e){return new VldExactOptional(e)}parse(e){if(void 0===e)return;const t=d(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const t=d(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullable extends VldBase{constructor(e){super(i.NULLABLE),this.baseValidator=e,this.simpleMode=u(e)}static create(e){return new VldNullable(e)}parse(e){if(null===e)return null;const t=d(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(null===e)return{success:!0,data:null};const t=d(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullish extends VldBase{constructor(e){super(i.NULLISH),this.baseValidator=e,this.simpleMode=u(e)}static create(e){return new VldNullish(e)}parse(e){if(null==e)return e;const t=d(this.simpleMode,e);return void 0!==t?t:this.baseValidator.parse(e)}safeParse(e){if(null==e)return{success:!0,data:e};const t=d(this.simpleMode,e);return void 0!==t?{success:!0,data:t}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldPipe extends VldBase{constructor(e,t){super(i.PIPE),this.first=e,this.second=t}parse(e){const t=this.first.parse(e);return this.second.parse(t)}safeParse(e){const t=this.first.safeParse(e);return t.success?this.second.safeParse(t.data):{success:!1,error:t.error}}}class VldSuperRefine extends VldBase{constructor(e,t){super(i.SUPER_REFINE),this._inner=e,this._refinement=t}parse(e){const s=this._inner.parse(e),r=[],a={addIssue:e=>{r.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(this._refinement(s,a)instanceof Promise)throw new Error("Use parseAsync for async refinements");if(r.length>0)throw new t.VldError(r,r.map(e=>e.message).join("; "));return s}safeParse(e){const r=this._inner.safeParse(e);if(!r.success)return{success:!1,error:s(r.error)};const a=[],i={addIssue:e=>{a.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(this._refinement(r.data,i)instanceof Promise)throw new Error("Use safeParseAsync for async refinements");return a.length>0?{success:!1,error:new t.VldError(a,a.map(e=>e.message).join("; "))}:r}async parseAsync(e){const s=await this._inner.parseAsync(e),r=[],a={addIssue:e=>{r.push({code:e.code||"custom",path:e.path??[],message:e.message||"Validation error"})},path:[]};if(await this._refinement(s,a),r.length>0)throw new t.VldError(r,r.map(e=>e.message).join("; "));return s}async safeParseAsync(e){try{return{success:!0,data:await this.parseAsync(e)}}catch(e){return{success:!1,error:s(e)}}}_wrap(e){return new VldSuperRefine(e,this._refinement)}min(e,t){return this._wrap(this._inner.min?.(e,t)??this._inner)}max(e,t){return this._wrap(this._inner.max?.(e,t)??this._inner)}length(e,t){return this._wrap(this._inner.length?.(e,t)??this._inner)}email(e){return this._wrap(this._inner.email?.(e)??this._inner)}url(e){return this._wrap(this._inner.url?.(e)??this._inner)}uuid(e){return this._wrap(this._inner.uuid?.(e)??this._inner)}regex(e,t){return this._wrap(this._inner.regex?.(e,t)??this._inner)}startsWith(e,t){return this._wrap(this._inner.startsWith?.(e,t)??this._inner)}endsWith(e,t){return this._wrap(this._inner.endsWith?.(e,t)??this._inner)}includes(e,t){return this._wrap(this._inner.includes?.(e,t)??this._inner)}ip(e){return this._wrap(this._inner.ip?.(e)??this._inner)}ipv4(e){return this._wrap(this._inner.ipv4?.(e)??this._inner)}ipv6(e){return this._wrap(this._inner.ipv6?.(e)??this._inner)}nonempty(e){return this._wrap(this._inner.nonempty?.(e)??this._inner)}trim(){return this._wrap(this._inner.trim?.()??this._inner)}toLowerCase(){return this._wrap(this._inner.toLowerCase?.()??this._inner)}lowercase(){return this.toLowerCase()}toUpperCase(){return this._wrap(this._inner.toUpperCase?.()??this._inner)}uppercase(){return this.toUpperCase()}positive(e){return this._wrap(this._inner.positive?.(e)??this._inner)}negative(e){return this._wrap(this._inner.negative?.(e)??this._inner)}nonnegative(e){return this._wrap(this._inner.nonnegative?.(e)??this._inner)}nonpositive(e){return this._wrap(this._inner.nonpositive?.(e)??this._inner)}int(e){return this._wrap(this._inner.int?.(e)??this._inner)}finite(e){return this._wrap(this._inner.finite?.(e)??this._inner)}safe(e){return this._wrap(this._inner.safe?.(e)??this._inner)}multipleOf(e,t){return this._wrap(this._inner.multipleOf?.(e,t)??this._inner)}step(e,t){return this._wrap(this._inner.step?.(e,t)??this._inner)}gt(e,t){return this._wrap(this._inner.gt?.(e,t)??this._inner)}gte(e,t){return this._wrap(this._inner.gte?.(e,t)??this._inner)}lt(e,t){return this._wrap(this._inner.lt?.(e,t)??this._inner)}lte(e,t){return this._wrap(this._inner.lte?.(e,t)??this._inner)}extend(e){return this._wrap(this._inner.extend?.(e)??this._inner)}merge(e){return this._wrap(this._inner.merge?.(e)??this._inner)}pick(...e){return this._wrap(this._inner.pick?.(...e)??this._inner)}omit(...e){return this._wrap(this._inner.omit?.(...e)??this._inner)}partial(){return this._wrap(this._inner.partial?.()??this._inner)}required(){return this._wrap(this._inner.required?.()??this._inner)}strict(e){return this._wrap(this._inner.strict?.(e)??this._inner)}passthrough(){return this._wrap(this._inner.passthrough?.()??this._inner)}strip(){return this._wrap(this._inner.strip?.()??this._inner)}catchall(e){return this._wrap(this._inner.catchall?.(e)??this._inner)}get shape(){return this._inner.shape}get keyof(){return this._inner.keyof}unwrap(){return this._inner.unwrap?this._inner.unwrap():this._inner}get element(){return this._inner.element}}class VldPreprocess extends VldBase{constructor(e,t){super(i.PREPROCESS),this._preprocessor=e,this._schema=t}static create(e,t){return new VldPreprocess(e,t)}parse(e){const t=this._preprocessor(e);return this._schema.parse(t)}safeParse(e){try{const t=this._preprocessor(e);return this._schema.safeParse(t)}catch(e){return{success:!1,error:s(e)}}}}exports.VLD_VALIDATOR_TYPES=i,exports.VldBase=VldBase,exports.VldBrand=VldBrand,exports.VldCatch=VldCatch,exports.VldDefault=VldDefault,exports.VldExactOptional=VldExactOptional,exports.VldMeta=VldMeta,exports.VldNullable=VldNullable,exports.VldNullish=VldNullish,exports.VldOptional=VldOptional,exports.VldPipe=VldPipe,exports.VldPrefault=VldPrefault,exports.VldPreprocess=VldPreprocess,exports.VldReadonly=VldReadonly,exports.VldRefine=VldRefine,exports.VldSuperRefine=VldSuperRefine,exports.VldTransform=VldTransform,exports.configureSchemaCompositionFactories=function(e){l=e},exports.ensureVldError=s,exports.isPromiseLike=o,exports.resolveErrorMessage=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var s=require("./base.cjs")
|
|
1
|
+
"use strict";var s=require("./base.cjs"),e=require("../chunks/errors-core-C0mA6tfa.cjs");require("../registry.cjs");class VldCustom extends s.VldBase{constructor(e){super(s.VLD_VALIDATOR_TYPES.CUSTOM),this._parseFn=e.parse,this._parseAsyncFn=e.parseAsync||(s=>Promise.resolve(this._parseFn(s))),this._safeParseFn=e.safeParse?r=>{const t=e.safeParse(r);return t.success?{success:!0,data:t.data}:{success:!1,error:s.ensureVldError(t.error)}}:e=>{try{return{success:!0,data:this._parseFn(e)}}catch(e){return{success:!1,error:s.ensureVldError(e)}}},this._safeParseAsyncFn=e.safeParseAsync?async r=>{const t=await e.safeParseAsync(r);return t.success?{success:!0,data:t.data}:{success:!1,error:s.ensureVldError(t.error)}}:async e=>{try{return{success:!0,data:await this._parseAsyncFn(e)}}catch(e){return{success:!1,error:s.ensureVldError(e)}}}}static create(s){return new VldCustom(s)}parse(s){return this._parseFn(s)}safeParse(s){return this._safeParseFn(s)}async parseAsync(s){return this._parseAsyncFn(s)}async safeParseAsync(s){return this._safeParseAsyncFn(s)}}function r(e,r){if("function"==typeof e){const t=e;return VldCustom.create({parse:e=>{if(!t(e))throw s.ensureVldError(s.resolveErrorMessage(r,"Custom validation failed"));return e}})}return e?VldCustom.create(e):VldCustom.create({parse:s=>s})}exports.VldCustom=VldCustom,exports.VldInstance=class extends VldCustom{constructor(s,r){super({parse:t=>{if(!(t instanceof s))throw new e.VldError([{code:"custom",path:[],message:r||`Expected instance of ${s.name||"provided constructor"}`}]);return t}}),this._cls=s,this._instanceMessage=r}properties(s,r){const t=this._cls,a=r?.message??this._instanceMessage,c=Object.entries(s);return VldCustom.create({parse:s=>{if(!(s instanceof t))throw new e.VldError([{code:"custom",path:[],message:a||`Expected instance of ${t.name||"provided constructor"}`}]);for(const[r,t]of c){const a=t.safeParse(s[r]);if(!a.success){const s=a.error.issues??[];throw new e.VldError(s.length>0?s.map(s=>({...s,path:[r,...s.path]})):[{code:"custom",path:[r],message:a.error.message}])}}return s}})}},exports.custom=r,exports.customFn=r;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./base.cjs"),s=require("../chunks/errors-core-C0mA6tfa.cjs"),r=require("../locales/runtime.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldNumberCheck{}class VldNumberCheckMin extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="min"}check(e){return e<this.threshold?{code:"too_small",path:[],origin:"number",minimum:this.threshold,inclusive:!0,message:this._msg||`Too small: expected number to be >=${this.threshold}`}:null}meta(){return{kind:"min",value:this.threshold,inclusive:!0,message:this._msg}}}class VldNumberCheckMax extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="max"}check(e){return e>this.threshold?{code:"too_big",path:[],origin:"number",maximum:this.threshold,inclusive:!0,message:this._msg||`Too big: expected number to be <=${this.threshold}`}:null}meta(){return{kind:"max",value:this.threshold,inclusive:!0,message:this._msg}}}class VldNumberCheckGt extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="gt"}check(e){return e<=this.threshold?{code:"too_small",path:[],origin:"number",minimum:this.threshold,inclusive:!1,message:this._msg||`Too small: expected number to be >${this.threshold}`}:null}meta(){return{kind:"gt",value:this.threshold,inclusive:!1,message:this._msg}}}class VldNumberCheckLt extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="lt"}check(e){return e>=this.threshold?{code:"too_big",path:[],origin:"number",maximum:this.threshold,inclusive:!1,message:this._msg||`Too big: expected number to be <${this.threshold}`}:null}meta(){return{kind:"lt",value:this.threshold,inclusive:!1,message:this._msg}}}class VldNumberCheckInt extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int"}check(e){return Number.isInteger(e)?null:{code:"invalid_type",path:[],expected:"int",received:"number",message:this._msg||"Invalid input: expected int, received number"}}meta(){return{kind:"int",message:this._msg}}}class VldNumberCheckFinite extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="finite"}check(e){return Number.isFinite(e)?null:{code:"custom",path:[],message:this._msg||"Number must be finite"}}meta(){return{kind:"finite",message:this._msg}}}class VldNumberCheckSafe extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="safe"}check(e){return Number.isSafeInteger(e)?null:{code:"custom",path:[],message:this._msg||"Number must be a safe integer"}}meta(){return{kind:"safe",message:this._msg}}}class VldNumberCheckMultipleOf extends VldNumberCheck{constructor(e,s){super(),this.divisor=e,this._msg=s,this.kind="multipleOf"}check(e){const s=Math.abs(e%this.divisor);return s<Number.EPSILON||Math.abs(s-Math.abs(this.divisor))<Number.EPSILON?null:{code:"custom",path:[],message:this._msg||`Number must be a multiple of ${this.divisor}`}}meta(){return{kind:"multipleOf",value:this.divisor,message:this._msg}}}class VldNumberCheckRange extends VldNumberCheck{constructor(e,s,r){super(),this.min=e,this.max=s,this._msg=r,this.kind="min"}check(e){return e<this.min||e>this.max?{code:"custom",path:[],message:this._msg||`Number must be between ${this.min} and ${this.max}`}:null}meta(){return{kind:"range",min:this.min,max:this.max,message:this._msg}}}class VldNumberCheckEven extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="even"}check(e){return Number.isInteger(e)&&e%2==0?null:{code:"custom",path:[],message:this._msg||"Number must be even"}}meta(){return{kind:"even",message:this._msg}}}class VldNumberCheckOdd extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="odd"}check(e){return Number.isInteger(e)&&e%2!=0?null:{code:"custom",path:[],message:this._msg||"Number must be odd"}}meta(){return{kind:"odd",message:this._msg}}}class VldNumberCheckUInt32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="uint32"}check(e){return!Number.isSafeInteger(e)||e<0||e>4294967295?{code:"custom",path:[],message:this._msg||"Expected an unsigned 32-bit integer"}:null}meta(){return{kind:"uint32",message:this._msg}}}class VldNumberCheckUInt64 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="uint64"}check(e){return!Number.isSafeInteger(e)||e<0?{code:"custom",path:[],message:this._msg||"Expected an unsigned 64-bit integer"}:null}meta(){return{kind:"uint64",message:this._msg}}}class VldNumberCheckInt32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int32"}check(e){return!Number.isSafeInteger(e)||e<-2147483648||e>2147483647?{code:"custom",path:[],message:this._msg||"Expected a signed 32-bit integer"}:null}meta(){return{kind:"int32",message:this._msg}}}class VldNumberCheckInt64 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int64"}check(e){return Number.isSafeInteger(e)?null:{code:"custom",path:[],message:this._msg||"Expected a signed 64-bit integer"}}meta(){return{kind:"int64",message:this._msg}}}class VldNumberCheckFloat32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="float32"}check(e){return!Number.isFinite(e)||Math.abs(e)>34e37?{code:"custom",path:[],message:this._msg||"Expected a 32-bit float"}:null}meta(){return{kind:"float32",message:this._msg}}}const t=Object.freeze({type:"number",checks:Object.freeze([]),isSimple:!0});class VldNumberV2 extends e.VldBase{constructor(s=t){super(e.VLD_VALIDATOR_TYPES.NUMBER),this.__def=s}static create(){return new VldNumberV2}get isSimple(){return this.__def.isSimple}get hasCustomChecks(){return!this.isSimple}get minValue(){const e=this.__def.jsonSchema;return e?.minimum??e?.exclusiveMinimum??null}get maxValue(){const e=this.__def.jsonSchema;return e?.maximum??e?.exclusiveMaximum??null}get isInt(){return"integer"===this.__def.jsonSchema?.type}get isFinite(){return!0}get getFormat(){return this.__def.jsonSchema?.format??null}get isCoercion(){return this.validatorType===e.VLD_VALIDATOR_TYPES.COERCE_NUMBER}parse(e){if("number"!=typeof e||!Number.isFinite(e))throw new s.VldError([s.createInvalidTypeIssue("number",s.getTypeName(e),this.__def.errorMessage)]);return this.__def.isSimple?e:this.parseKnownNumber(e)}parseKnownNumber(e){const r=this.__def.checks;for(let t=0;t<r.length;t++){const i=r[t].check(e);if(null!==i)throw new s.VldError([i])}return e}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:e instanceof s.VldError?e:new s.VldError([{code:"custom",path:[],message:String(e)}])}}}withDef(e){const s=(r=e.checks??this.__def.checks,t=e.jsonSchema??this.__def.jsonSchema,i=e.errorMessage??this.__def.errorMessage,Object.freeze({type:"number",checks:r,jsonSchema:t,errorMessage:i,isSimple:0===r.length}));var r,t,i;return new this.constructor(s)}min(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMin(s,e.resolveErrorMessage(t,r.getMessages().numberMin(s)))],jsonSchema:{...this.__def.jsonSchema,minimum:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMin(s))})}max(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMax(s,e.resolveErrorMessage(t,r.getMessages().numberMax(s)))],jsonSchema:{...this.__def.jsonSchema,maximum:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMax(s))})}int(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt(e.resolveErrorMessage(s,r.getMessages().numberInt))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberInt)})}positive(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckGt(0,e.resolveErrorMessage(s,r.getMessages().numberPositive))],jsonSchema:{...this.__def.jsonSchema,exclusiveMinimum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberPositive)})}negative(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckLt(0,e.resolveErrorMessage(s,r.getMessages().numberNegative))],jsonSchema:{...this.__def.jsonSchema,exclusiveMaximum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNegative)})}nonnegative(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMin(0,e.resolveErrorMessage(s,r.getMessages().numberNonnegative))],jsonSchema:{...this.__def.jsonSchema,minimum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNonnegative)})}nonpositive(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMax(0,e.resolveErrorMessage(s,r.getMessages().numberNonpositive))],jsonSchema:{...this.__def.jsonSchema,maximum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNonpositive)})}finite(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFinite(e.resolveErrorMessage(s,r.getMessages().numberFinite))],errorMessage:e.resolveErrorMessage(s,r.getMessages().numberFinite)})}safe(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckSafe(e.resolveErrorMessage(s,r.getMessages().numberSafe))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberSafe)})}multipleOf(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMultipleOf(s,e.resolveErrorMessage(t,r.getMessages().numberMultipleOf(s)))],jsonSchema:{...this.__def.jsonSchema,multipleOf:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMultipleOf(s))})}step(e,s){return this.multipleOf(e,s)}between(s,r,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckRange(s,r,e.resolveErrorMessage(t,`Number must be between ${s} and ${r}`))],jsonSchema:{...this.__def.jsonSchema,minimum:s,maximum:r},errorMessage:e.resolveErrorMessage(t,`Number must be between ${s} and ${r}`)})}even(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckEven(e.resolveErrorMessage(s,"Number must be even"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",multipleOf:2},errorMessage:e.resolveErrorMessage(s,"Number must be even")})}odd(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckOdd(e.resolveErrorMessage(s,"Number must be odd"))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,"Number must be odd")})}gt(s,r){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckGt(s,e.resolveErrorMessage(r,`Number must be greater than ${s}`))],jsonSchema:{...this.__def.jsonSchema,exclusiveMinimum:s},errorMessage:e.resolveErrorMessage(r,`Number must be greater than ${s}`)})}lt(s,r){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckLt(s,e.resolveErrorMessage(r,`Number must be less than ${s}`))],jsonSchema:{...this.__def.jsonSchema,exclusiveMaximum:s},errorMessage:e.resolveErrorMessage(r,`Number must be less than ${s}`)})}gte(e,s){return this.min(e,s)}lte(e,s){return this.max(e,s)}uint32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckUInt32(e.resolveErrorMessage(s,"Expected an unsigned 32-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:0,maximum:4294967295},errorMessage:e.resolveErrorMessage(s,"Expected an unsigned 32-bit integer")})}uint64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckUInt64(e.resolveErrorMessage(s,"Expected an unsigned 64-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:0},errorMessage:e.resolveErrorMessage(s,"Expected an unsigned 64-bit integer")})}int32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt32(e.resolveErrorMessage(s,"Expected a signed 32-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:-2147483648,maximum:2147483647},errorMessage:e.resolveErrorMessage(s,"Expected a signed 32-bit integer")})}int64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt64(e.resolveErrorMessage(s,"Expected a signed 64-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,"Expected a signed 64-bit integer")})}float32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFloat32(e.resolveErrorMessage(s,"Expected a 32-bit float"))],jsonSchema:{...this.__def.jsonSchema,minimum:-34e37,maximum:34e37},errorMessage:e.resolveErrorMessage(s,"Expected a 32-bit float")})}float64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFinite(e.resolveErrorMessage(s,"Expected a 64-bit float"))],errorMessage:e.resolveErrorMessage(s,"Expected a 64-bit float")})}}const i=Object.freeze({type:"number",checks:Object.freeze([]),isSimple:!0});class VldCoerceNumberV2 extends VldNumberV2{constructor(s=i){super(s),this.validatorType=e.VLD_VALIDATOR_TYPES.COERCE_NUMBER}static create(){return new VldCoerceNumberV2}parse(e){let s;if("number"==typeof e)s=e;else if("string"==typeof e&&""!==e.trim()){const t=Number(e);if(Number.isNaN(t))throw new Error(r.getMessages().coercionFailed("number",e));s=t}else if("boolean"==typeof e)s=e?1:0;else if("bigint"==typeof e){const t=Number(e);if(Number.isNaN(t))throw new Error(r.getMessages().coercionFailed("number",e));s=t}else{if(null!==e)throw new Error(r.getMessages().coercionFailed("number",e));s=0}if(!Number.isFinite(s))throw new Error(r.getMessages().coercionFailed("number",e));return super.parse(s)}}exports.VldCoerceNumberV2=VldCoerceNumberV2,exports.VldNumberCheck=VldNumberCheck,exports.VldNumberCheckEven=VldNumberCheckEven,exports.VldNumberCheckFinite=VldNumberCheckFinite,exports.VldNumberCheckFloat32=VldNumberCheckFloat32,exports.VldNumberCheckGt=VldNumberCheckGt,exports.VldNumberCheckInt=VldNumberCheckInt,exports.VldNumberCheckInt32=VldNumberCheckInt32,exports.VldNumberCheckInt64=VldNumberCheckInt64,exports.VldNumberCheckLt=VldNumberCheckLt,exports.VldNumberCheckMax=VldNumberCheckMax,exports.VldNumberCheckMin=VldNumberCheckMin,exports.VldNumberCheckMultipleOf=VldNumberCheckMultipleOf,exports.VldNumberCheckOdd=VldNumberCheckOdd,exports.VldNumberCheckRange=VldNumberCheckRange,exports.VldNumberCheckSafe=VldNumberCheckSafe,exports.VldNumberCheckUInt32=VldNumberCheckUInt32,exports.VldNumberCheckUInt64=VldNumberCheckUInt64,exports.VldNumberV2=VldNumberV2;
|
|
1
|
+
"use strict";var e=require("./base.cjs"),s=require("../chunks/errors-core-C0mA6tfa.cjs"),r=require("../locales/runtime.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldNumberCheck{}class VldNumberCheckMin extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="min"}check(e){return e<this.threshold?{code:"too_small",path:[],origin:"number",minimum:this.threshold,inclusive:!0,message:this._msg||`Too small: expected number to be >=${this.threshold}`}:null}meta(){return{kind:"min",value:this.threshold,inclusive:!0,message:this._msg}}}class VldNumberCheckMax extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="max"}check(e){return e>this.threshold?{code:"too_big",path:[],origin:"number",maximum:this.threshold,inclusive:!0,message:this._msg||`Too big: expected number to be <=${this.threshold}`}:null}meta(){return{kind:"max",value:this.threshold,inclusive:!0,message:this._msg}}}class VldNumberCheckGt extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="gt"}check(e){return e<=this.threshold?{code:"too_small",path:[],origin:"number",minimum:this.threshold,inclusive:!1,message:this._msg||`Too small: expected number to be >${this.threshold}`}:null}meta(){return{kind:"gt",value:this.threshold,inclusive:!1,message:this._msg}}}class VldNumberCheckLt extends VldNumberCheck{constructor(e,s){super(),this.threshold=e,this._msg=s,this.kind="lt"}check(e){return e>=this.threshold?{code:"too_big",path:[],origin:"number",maximum:this.threshold,inclusive:!1,message:this._msg||`Too big: expected number to be <${this.threshold}`}:null}meta(){return{kind:"lt",value:this.threshold,inclusive:!1,message:this._msg}}}class VldNumberCheckInt extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int"}check(e){return Number.isInteger(e)?null:{code:"invalid_type",path:[],expected:"int",received:"number",message:this._msg||"Invalid input: expected int, received number"}}meta(){return{kind:"int",message:this._msg}}}class VldNumberCheckFinite extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="finite"}check(e){return Number.isFinite(e)?null:{code:"custom",path:[],message:this._msg||"Number must be finite"}}meta(){return{kind:"finite",message:this._msg}}}class VldNumberCheckSafe extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="safe"}check(e){return Number.isSafeInteger(e)?null:{code:"custom",path:[],message:this._msg||"Number must be a safe integer"}}meta(){return{kind:"safe",message:this._msg}}}class VldNumberCheckMultipleOf extends VldNumberCheck{constructor(e,s){super(),this.divisor=e,this._msg=s,this.kind="multipleOf"}check(e){const s=Math.abs(e%this.divisor);return s<Number.EPSILON||Math.abs(s-Math.abs(this.divisor))<Number.EPSILON?null:{code:"custom",path:[],message:this._msg||`Number must be a multiple of ${this.divisor}`}}meta(){return{kind:"multipleOf",value:this.divisor,message:this._msg}}}class VldNumberCheckRange extends VldNumberCheck{constructor(e,s,r){super(),this.min=e,this.max=s,this._msg=r,this.kind="min"}check(e){return e<this.min||e>this.max?{code:"custom",path:[],message:this._msg||`Number must be between ${this.min} and ${this.max}`}:null}meta(){return{kind:"range",min:this.min,max:this.max,message:this._msg}}}class VldNumberCheckEven extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="even"}check(e){return Number.isInteger(e)&&e%2==0?null:{code:"custom",path:[],message:this._msg||"Number must be even"}}meta(){return{kind:"even",message:this._msg}}}class VldNumberCheckOdd extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="odd"}check(e){return Number.isInteger(e)&&e%2!=0?null:{code:"custom",path:[],message:this._msg||"Number must be odd"}}meta(){return{kind:"odd",message:this._msg}}}class VldNumberCheckUInt32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="uint32"}check(e){return!Number.isSafeInteger(e)||e<0||e>4294967295?{code:"custom",path:[],message:this._msg||"Expected an unsigned 32-bit integer"}:null}meta(){return{kind:"uint32",message:this._msg}}}class VldNumberCheckUInt64 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="uint64"}check(e){return!Number.isSafeInteger(e)||e<0?{code:"custom",path:[],message:this._msg||"Expected an unsigned 64-bit integer"}:null}meta(){return{kind:"uint64",message:this._msg}}}class VldNumberCheckInt32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int32"}check(e){return!Number.isSafeInteger(e)||e<-2147483648||e>2147483647?{code:"custom",path:[],message:this._msg||"Expected a signed 32-bit integer"}:null}meta(){return{kind:"int32",message:this._msg}}}class VldNumberCheckInt64 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="int64"}check(e){return Number.isSafeInteger(e)?null:{code:"custom",path:[],message:this._msg||"Expected a signed 64-bit integer"}}meta(){return{kind:"int64",message:this._msg}}}class VldNumberCheckFloat32 extends VldNumberCheck{constructor(e){super(),this._msg=e,this.kind="float32"}check(e){return!Number.isFinite(e)||Math.abs(e)>34e37?{code:"custom",path:[],message:this._msg||"Expected a 32-bit float"}:null}meta(){return{kind:"float32",message:this._msg}}}const t=Object.freeze({type:"number",checks:Object.freeze([]),isSimple:!0});class VldNumberV2 extends e.VldBase{constructor(s=t){super(e.VLD_VALIDATOR_TYPES.NUMBER),this.__def=s}static create(){return new VldNumberV2}get isSimple(){return this.__def.isSimple}get hasCustomChecks(){return!this.isSimple}get minValue(){const e=this.__def.jsonSchema;return e?.minimum??e?.exclusiveMinimum??null}get maxValue(){const e=this.__def.jsonSchema;return e?.maximum??e?.exclusiveMaximum??null}get isInt(){return"integer"===this.__def.jsonSchema?.type}get isFinite(){return!0}get getFormat(){return this.__def.jsonSchema?.format??null}get isCoercion(){return this.validatorType===e.VLD_VALIDATOR_TYPES.COERCE_NUMBER}parse(e){if("number"!=typeof e||!Number.isFinite(e))throw new s.VldError([s.createInvalidTypeIssue("number",s.getTypeName(e),this.__def.errorMessage)]);return this.__def.isSimple?e:this.parseKnownNumber(e)}parseKnownNumber(e){const r=this.__def.checks;for(let t=0;t<r.length;t++){const i=r[t].check(e);if(null!==i)throw new s.VldError([i])}return e}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:e instanceof s.VldError?e:new s.VldError([{code:"custom",path:[],message:String(e)}])}}}withDef(e){const s=(r=e.checks??this.__def.checks,t=e.jsonSchema??this.__def.jsonSchema,i=e.errorMessage??this.__def.errorMessage,Object.freeze({type:"number",checks:r,jsonSchema:t,errorMessage:i,isSimple:0===r.length}));var r,t,i;return new this.constructor(s)}min(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMin(s,e.resolveErrorMessage(t,r.getMessages().numberMin(s)))],jsonSchema:{...this.__def.jsonSchema,minimum:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMin(s))})}max(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMax(s,e.resolveErrorMessage(t,r.getMessages().numberMax(s)))],jsonSchema:{...this.__def.jsonSchema,maximum:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMax(s))})}int(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt(e.resolveErrorMessage(s,r.getMessages().numberInt))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberInt)})}positive(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckGt(0,e.resolveErrorMessage(s,r.getMessages().numberPositive))],jsonSchema:{...this.__def.jsonSchema,exclusiveMinimum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberPositive)})}negative(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckLt(0,e.resolveErrorMessage(s,r.getMessages().numberNegative))],jsonSchema:{...this.__def.jsonSchema,exclusiveMaximum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNegative)})}nonnegative(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMin(0,e.resolveErrorMessage(s,r.getMessages().numberNonnegative))],jsonSchema:{...this.__def.jsonSchema,minimum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNonnegative)})}nonpositive(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMax(0,e.resolveErrorMessage(s,r.getMessages().numberNonpositive))],jsonSchema:{...this.__def.jsonSchema,maximum:0},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberNonpositive)})}finite(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFinite(e.resolveErrorMessage(s,r.getMessages().numberFinite))],errorMessage:e.resolveErrorMessage(s,r.getMessages().numberFinite)})}safe(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckSafe(e.resolveErrorMessage(s,r.getMessages().numberSafe))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,r.getMessages().numberSafe)})}multipleOf(s,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckMultipleOf(s,e.resolveErrorMessage(t,r.getMessages().numberMultipleOf(s)))],jsonSchema:{...this.__def.jsonSchema,multipleOf:s},errorMessage:e.resolveErrorMessage(t,r.getMessages().numberMultipleOf(s))})}step(e,s){return this.multipleOf(e,s)}between(s,r,t){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckRange(s,r,e.resolveErrorMessage(t,`Number must be between ${s} and ${r}`))],jsonSchema:{...this.__def.jsonSchema,minimum:s,maximum:r},errorMessage:e.resolveErrorMessage(t,`Number must be between ${s} and ${r}`)})}even(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckEven(e.resolveErrorMessage(s,"Number must be even"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",multipleOf:2},errorMessage:e.resolveErrorMessage(s,"Number must be even")})}odd(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckOdd(e.resolveErrorMessage(s,"Number must be odd"))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,"Number must be odd")})}gt(s,r){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckGt(s,e.resolveErrorMessage(r,`Number must be greater than ${s}`))],jsonSchema:{...this.__def.jsonSchema,exclusiveMinimum:s},errorMessage:e.resolveErrorMessage(r,`Number must be greater than ${s}`)})}lt(s,r){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckLt(s,e.resolveErrorMessage(r,`Number must be less than ${s}`))],jsonSchema:{...this.__def.jsonSchema,exclusiveMaximum:s},errorMessage:e.resolveErrorMessage(r,`Number must be less than ${s}`)})}gte(e,s){return this.min(e,s)}lte(e,s){return this.max(e,s)}uint32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckUInt32(e.resolveErrorMessage(s,"Expected an unsigned 32-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:0,maximum:4294967295},errorMessage:e.resolveErrorMessage(s,"Expected an unsigned 32-bit integer")})}uint64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckUInt64(e.resolveErrorMessage(s,"Expected an unsigned 64-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:0},errorMessage:e.resolveErrorMessage(s,"Expected an unsigned 64-bit integer")})}int32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt32(e.resolveErrorMessage(s,"Expected a signed 32-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer",minimum:-2147483648,maximum:2147483647},errorMessage:e.resolveErrorMessage(s,"Expected a signed 32-bit integer")})}int64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckInt64(e.resolveErrorMessage(s,"Expected a signed 64-bit integer"))],jsonSchema:{...this.__def.jsonSchema,type:"integer"},errorMessage:e.resolveErrorMessage(s,"Expected a signed 64-bit integer")})}float32(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFloat32(e.resolveErrorMessage(s,"Expected a 32-bit float"))],jsonSchema:{...this.__def.jsonSchema,minimum:-34e37,maximum:34e37},errorMessage:e.resolveErrorMessage(s,"Expected a 32-bit float")})}float64(s){return this.withDef({type:"number",checks:[...this.__def.checks,new VldNumberCheckFinite(e.resolveErrorMessage(s,"Expected a 64-bit float"))],errorMessage:e.resolveErrorMessage(s,"Expected a 64-bit float")})}}const i=Object.freeze({type:"number",checks:Object.freeze([]),isSimple:!0});class VldCoerceNumberV2 extends VldNumberV2{constructor(s=i){super(s),this.validatorType=e.VLD_VALIDATOR_TYPES.COERCE_NUMBER}static create(){return new VldCoerceNumberV2}parse(e){let s;if("number"==typeof e)s=e;else if("string"==typeof e&&""!==e.trim()){const t=Number(e);if(Number.isNaN(t))throw new Error(r.getMessages().coercionFailed("number",e));s=t}else if("boolean"==typeof e)s=e?1:0;else if("bigint"==typeof e)s=Number(e);else{if(null!==e)throw new Error(r.getMessages().coercionFailed("number",e));s=0}if(!Number.isFinite(s))throw new Error(r.getMessages().coercionFailed("number",e));return super.parse(s)}}exports.VldCoerceNumberV2=VldCoerceNumberV2,exports.VldNumberCheck=VldNumberCheck,exports.VldNumberCheckEven=VldNumberCheckEven,exports.VldNumberCheckFinite=VldNumberCheckFinite,exports.VldNumberCheckFloat32=VldNumberCheckFloat32,exports.VldNumberCheckGt=VldNumberCheckGt,exports.VldNumberCheckInt=VldNumberCheckInt,exports.VldNumberCheckInt32=VldNumberCheckInt32,exports.VldNumberCheckInt64=VldNumberCheckInt64,exports.VldNumberCheckLt=VldNumberCheckLt,exports.VldNumberCheckMax=VldNumberCheckMax,exports.VldNumberCheckMin=VldNumberCheckMin,exports.VldNumberCheckMultipleOf=VldNumberCheckMultipleOf,exports.VldNumberCheckOdd=VldNumberCheckOdd,exports.VldNumberCheckRange=VldNumberCheckRange,exports.VldNumberCheckSafe=VldNumberCheckSafe,exports.VldNumberCheckUInt32=VldNumberCheckUInt32,exports.VldNumberCheckUInt64=VldNumberCheckUInt64,exports.VldNumberV2=VldNumberV2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./base.cjs"),s=require("../locales/runtime.cjs"),t=require("./enum.cjs"),i=require("../chunks/security-aXZVI7qW.cjs"),r=require("../chunks/errors-core-C0mA6tfa.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldObject extends e.VldBase{createSafeParseError(e,t){if(e instanceof r.VldError)return void 0!==t?new r.VldError(e.issues.map(e=>({...e,path:e.path?[t,...e.path]:[t],message:e.message.startsWith("Invalid field")?e.message:s.getMessages().objectField(String(t),e.message)}))):e;const i=e instanceof Error?e.message:String(e);return new r.VldError([{code:"invalid_type",path:void 0!==t?[t]:[],message:void 0===t||i.startsWith("Invalid field")?i:s.getMessages().objectField(String(t),i)}])}constructor(s){super(e.VLD_VALIDATOR_TYPES.OBJECT),this._config=s,this._shapeKeys=Object.keys(s.shape),this._shapeKeysSet=new Set(this._shapeKeys),this._validators=this._shapeKeys.map(e=>this.tryGetFieldValidator(e)),this._validatorTypes=this._shapeKeys.map((e,s)=>this._validators[s]?.validatorType||this.getValidatorType(e)),this._simpleFieldModes=this._validators.map((e,s)=>this.getSimpleFieldMode(e,this._validatorTypes[s])),this._simpleFieldValues=this._validators.map((e,s)=>"literal"===this._simpleFieldModes[s]?e.literal:void 0),this._canUseSimpleObjectFastPath=!s.strict&&!s.passthrough&&!s.catchall&&this._shapeKeys.length>0&&this._simpleFieldModes.every(e=>void 0!==e),this._canUseSafeParseFastPath=this._validators.every(s=>s instanceof e.VldBase)&&(void 0===s.catchall||s.catchall instanceof e.VldBase)}tryGetFieldValidator(e){try{const s=Object.getOwnPropertyDescriptor(this._config.shape,e);if(s?.get)return;return this.resolveFieldValidator(e)}catch{return}}resolveFieldValidator(e){try{const s=this._config.shape[e];if(!s||"function"!=typeof s.safeParse)return;return s}catch{return}}getFieldValidator(e,s){const t=(void 0===s?void 0:this._validators[s])||this.resolveFieldValidator(e);if(!t)throw new Error(`Invalid validator for field "${e}"`);return t}getValidatorType(s){try{const t=this._config.shape[s];return t?.validatorType||e.VLD_VALIDATOR_TYPES.UNKNOWN}catch{return e.VLD_VALIDATOR_TYPES.UNKNOWN}}getSimpleFieldMode(s,t){if(s&&!0===s.isSimple)switch(t){case e.VLD_VALIDATOR_TYPES.STRING:return"string";case e.VLD_VALIDATOR_TYPES.NUMBER:return"number";case e.VLD_VALIDATOR_TYPES.BOOLEAN:return"boolean";case e.VLD_VALIDATOR_TYPES.BIGINT:return"bigint";case e.VLD_VALIDATOR_TYPES.SYMBOL:return"symbol";case e.VLD_VALIDATOR_TYPES.NULL:return"null";case e.VLD_VALIDATOR_TYPES.UNDEFINED:case e.VLD_VALIDATOR_TYPES.VOID:return"undefinedValue";case e.VLD_VALIDATOR_TYPES.LITERAL:return"literal";case e.VLD_VALIDATOR_TYPES.ANY:case e.VLD_VALIDATOR_TYPES.UNKNOWN:return"passthrough";default:return}}getSimpleFieldError(e,t,i){switch(e){case"string":return s.getMessages().invalidString;case"number":return s.getMessages().invalidNumber;case"boolean":return s.getMessages().invalidBoolean;case"bigint":return s.getMessages().invalidBigint;case"symbol":return s.getMessages().invalidSymbol;case"null":return"Expected null, received "+typeof i;case"undefinedValue":return s.getMessages().expectedUndefined;case"literal":return s.getMessages().literalExpected(JSON.stringify(t),JSON.stringify(i));default:return s.getMessages().invalidObject}}parseCheckedField(s,t,i){if(t===e.VLD_VALIDATOR_TYPES.STRING&&"string"==typeof i){const e=s.parseKnownString;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.NUMBER&&"number"==typeof i&&!isNaN(i)){const e=s.parseKnownNumber;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.BOOLEAN&&"boolean"==typeof i){const e=s.parseKnownBoolean;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.BIGINT&&"bigint"==typeof i){const e=s.parseKnownBigInt;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.SYMBOL&&"symbol"==typeof i){const e=s.parseKnownSymbol;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.FUNCTION&&"function"==typeof i){const e=s.parseKnownFunction;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.FILE&&"object"==typeof i&&null!==i&&("size"in i&&"type"in i||"undefined"!=typeof File&&i instanceof File)){const e=s.parseKnownFile;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.DATE&&i instanceof Date){const e=s.parseKnownDate;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.OBJECT&&"object"==typeof i&&null!==i&&!Array.isArray(i)){const e=s.parseKnownObject;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.ARRAY&&Array.isArray(i)){const e=s.parseKnownArray;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.TUPLE&&Array.isArray(i)){const e=s.parseKnownTuple;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.RECORD&&"object"==typeof i&&null!==i&&!Array.isArray(i)){const e=s.parseKnownRecord;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.SET&&i instanceof Set){const e=s.parseKnownSet;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.MAP&&i instanceof Map){const e=s.parseKnownMap;if("function"==typeof e)return e.call(s,i)}return s.parse(i)}parseSimpleObjectValue(e,t,i=!1){if(2===this._shapeKeys.length&&"string"===this._simpleFieldModes[0]&&"number"===this._simpleFieldModes[1]){const t=this._shapeKeys[0],i=e[t];if("string"!=typeof i)throw new Error(s.getMessages().objectField(t,s.getMessages().invalidString));const r=this._shapeKeys[1],n=e[r];if("number"!=typeof n||isNaN(n))throw new Error(s.getMessages().objectField(r,s.getMessages().invalidNumber));const a={};return a[t]=i,a[r]=n,a}if(3===this._shapeKeys.length&&"literal"===this._simpleFieldModes[0]&&"string"===this._simpleFieldModes[1]&&"number"===this._simpleFieldModes[2]){const r=this._shapeKeys[0],n=e[r],a=this._simpleFieldValues[0];if((!i||r!==t)&&n!==a)throw new Error(s.getMessages().objectField(r,this.getSimpleFieldError("literal",a,n)));const o=this._shapeKeys[1],c=e[o];if("string"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidString));const l=this._shapeKeys[2],h=e[l];if("number"!=typeof h||isNaN(h))throw new Error(s.getMessages().objectField(l,s.getMessages().invalidNumber));const f={};return f[r]=a,f[o]=c,f[l]=h,f}const r={};for(let n=0;n<this._shapeKeys.length;n++){const a=this._shapeKeys[n],o=e[a],c=this._simpleFieldModes[n];switch(c){case"string":if("string"!=typeof o)throw new Error(s.getMessages().objectField(a,s.getMessages().invalidString));r[a]=o;break;case"number":if("number"!=typeof o||isNaN(o))throw new Error(s.getMessages().objectField(a,s.getMessages().invalidNumber));r[a]=o;break;case"boolean":if("boolean"!=typeof o)throw new Error(s.getMessages().objectField(a,s.getMessages().invalidBoolean));r[a]=o;break;case"bigint":if("bigint"!=typeof o)throw new Error(s.getMessages().objectField(a,s.getMessages().invalidBigint));r[a]=o;break;case"symbol":if("symbol"!=typeof o)throw new Error(s.getMessages().objectField(a,s.getMessages().invalidSymbol));r[a]=o;break;case"null":if(null!==o)throw new Error(s.getMessages().objectField(a,this.getSimpleFieldError(c,void 0,o)));r[a]=null;break;case"undefinedValue":if(void 0!==o)throw new Error(s.getMessages().objectField(a,s.getMessages().expectedUndefined));r[a]=void 0;break;case"literal":if(i&&a===t){r[a]=this._simpleFieldValues[n];break}if(o!==this._simpleFieldValues[n])throw new Error(s.getMessages().objectField(a,this.getSimpleFieldError(c,this._simpleFieldValues[n],o)));r[a]=this._simpleFieldValues[n];break;case"passthrough":r[a]=o;break;default:throw new Error(s.getMessages().objectField(a,s.getMessages().invalidObject))}}return r}get config(){return this._config}get shapeKeys(){return this._shapeKeys}get shapeKeysSet(){return this._shapeKeysSet}static create(e){return new VldObject({shape:e})}parse(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.parseObjectValue(e)}parseKnownObject(e,s){return this.parseObjectValue(e,s)}parseTrustedKnownObject(e,s){return this.parseObjectValue(e,s,!0)}parseObjectValue(e,t,n=!1){if(this._canUseSimpleObjectFastPath)return this.parseSimpleObjectValue(e,t,n);const a={};let o="";try{for(let i=0;i<this._shapeKeys.length;i++){if(o=this._shapeKeys[i],n&&o===t&&"literal"===this._simpleFieldModes[i]){a[o]=this._simpleFieldValues[i];continue}const r=this._simpleFieldModes[i];if(void 0!==r){const t=e[o];switch(r){case"string":if("string"!=typeof t)throw new Error(s.getMessages().invalidString);a[o]=t;continue;case"number":if("number"!=typeof t||isNaN(t))throw new Error(s.getMessages().invalidNumber);a[o]=t;continue;case"boolean":if("boolean"!=typeof t)throw new Error(s.getMessages().invalidBoolean);a[o]=t;continue;case"bigint":if("bigint"!=typeof t)throw new Error(s.getMessages().invalidBigint);a[o]=t;continue;case"symbol":if("symbol"!=typeof t)throw new Error(s.getMessages().invalidSymbol);a[o]=t;continue;case"null":if(null!==t)throw new Error(this.getSimpleFieldError(r,void 0,t));a[o]=null;continue;case"undefinedValue":if(void 0!==t)throw new Error(s.getMessages().expectedUndefined);a[o]=void 0;continue;case"literal":if(t!==this._simpleFieldValues[i])throw new Error(this.getSimpleFieldError(r,this._simpleFieldValues[i],t));a[o]=this._simpleFieldValues[i];continue;case"passthrough":a[o]=t;continue}continue}const c=this.getFieldValidator(o,i);a[o]=this.parseCheckedField(c,this._validatorTypes[i],e[o])}}catch(e){if(e instanceof r.VldError)throw new r.VldError(e.issues.map(e=>({...e,path:e.path?[o,...e.path]:[o],message:s.getMessages().objectField(o,e.message.startsWith("Invalid field")?e.message.replace(/^Invalid field "[^"]+": /,""):e.message)})));const t=e instanceof Error?e.message:String(e);throw new r.VldError([{code:"invalid_type",path:[o],message:t.startsWith("Invalid field")?t:s.getMessages().objectField(o,t)}])}if(this._config.strict||this._config.passthrough||this._config.catchall){const t=Object.keys(e);if(this._config.strict){const e=[];for(let s=0;s<t.length;s++){const i=t[s];this._shapeKeysSet.has(i)||e.push(i)}if(e.length>0)throw new Error(s.getMessages().unexpectedKeys(e))}if(this._config.passthrough)for(let s=0;s<t.length;s++){const r=t[s];this._shapeKeysSet.has(r)||i.isDangerousKey(r)||(a[r]=e[r])}if(this._config.catchall)for(let r=0;r<t.length;r++){const n=t[r];if(!this._shapeKeysSet.has(n)&&!i.isDangerousKey(n))try{a[n]=this._config.catchall.parse(e[n])}catch(e){throw new Error(s.getMessages().objectField(n,e.message))}}}return a}safeParse(t){if("object"!=typeof t||null===t||Array.isArray(t))return{success:!1,error:this.createSafeParseError(this._config.errorMessage||s.getMessages().invalidObject)};const n=t;if(this._canUseSimpleObjectFastPath)try{return{success:!0,data:this.parseSimpleObjectValue(n)}}catch{}if(this._canUseSafeParseFastPath)try{return{success:!0,data:this.parseObjectValue(n)}}catch{}const a={},o=[];for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=n[i],c=this._simpleFieldModes[t];if(void 0!==c){if("string"===c&&"string"==typeof r||"number"===c&&"number"==typeof r&&!isNaN(r)||"boolean"===c&&"boolean"==typeof r||"bigint"===c&&"bigint"==typeof r||"symbol"===c&&"symbol"==typeof r||"null"===c&&null===r||"undefinedValue"===c&&void 0===r||"literal"===c&&r===this._simpleFieldValues[t]||"passthrough"===c){a[i]="literal"===c?this._simpleFieldValues[t]:"null"===c?null:r;continue}o.push({code:"invalid_type",path:[i],message:s.getMessages().objectField(i,this.getSimpleFieldError(c,this._simpleFieldValues[t],r))});continue}let l;try{l=this.getFieldValidator(i,t)}catch(e){const s=this.createSafeParseError(e,i);o.push(...s.issues);continue}try{if(l instanceof e.VldBase)a[i]=this.parseCheckedField(l,this._validatorTypes[t],r);else{const e=l.safeParse(r);if(e.success)a[i]=e.data;else{const s=this.createSafeParseError(e.error,i);o.push(...s.issues)}}}catch(e){const s=this.createSafeParseError(e,i);o.push(...s.issues)}}if(this._config.strict||this._config.passthrough||this._config.catchall){const t=Object.keys(n);if(this._config.strict){const e=[];for(let s=0;s<t.length;s++){const i=t[s];this._shapeKeysSet.has(i)||e.push(i)}e.length>0&&o.push(...e.map(e=>({code:"unrecognized_keys",path:[e],message:s.getMessages().unexpectedKeys([e])})))}if(this._config.passthrough)for(let e=0;e<t.length;e++){const s=t[e];this._shapeKeysSet.has(s)||i.isDangerousKey(s)||(a[s]=n[s])}if(this._config.catchall){const s=this._config.catchall;for(let r=0;r<t.length;r++){const c=t[r];if(!this._shapeKeysSet.has(c)&&!i.isDangerousKey(c))try{if(s instanceof e.VldBase)a[c]=s.parse(n[c]);else{const e=s.safeParse(n[c]);if(e.success)a[c]=e.data;else{const s=this.createSafeParseError(e.error,c);o.push(...s.issues)}}}catch(e){const s=this.createSafeParseError(e,c);o.push(...s.issues)}}}}return o.length>0?{success:!1,error:new r.VldError(o)}:{success:!0,data:a}}encode(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.encodeObjectSync(e)}safeEncode(e){try{return{success:!0,data:this.encode(e)}}catch(e){return{success:!1,error:this.createSafeParseError(e.message)}}}async encodeAsync(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.encodeObjectAsync(e)}async safeEncodeAsync(e){try{return{success:!0,data:await this.encodeAsync(e)}}catch(e){return{success:!1,error:this.createSafeParseError(e.message)}}}encodeObjectSync(e){const s={};for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=this.getFieldValidator(i,t).encode(e[i]);(void 0!==r||Object.prototype.hasOwnProperty.call(e,i))&&(s[i]=r)}return this.encodeExtraKeysSync(e,s),s}async encodeObjectAsync(e){const s={};for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=await this.getFieldValidator(i,t).encodeAsync(e[i]);(void 0!==r||Object.prototype.hasOwnProperty.call(e,i))&&(s[i]=r)}const t=this.getEncodedExtraKeys(e);for(const r of t)i.isDangerousKey(r)||(this._config.catchall?s[r]=await this._config.catchall.encodeAsync(e[r]):this._config.passthrough&&(s[r]=e[r]));return s}getEncodedExtraKeys(e){const t=Object.keys(e).filter(e=>!this._shapeKeysSet.has(e));if(this._config.strict&&t.length>0)throw new Error(s.getMessages().unexpectedKeys(t));return t}encodeExtraKeysSync(e,s){for(const t of this.getEncodedExtraKeys(e))i.isDangerousKey(t)||(this._config.catchall?s[t]=this._config.catchall.encode(e[t]):this._config.passthrough&&(s[t]=e[t]))}strict(e){return new VldObject({...this._config,strict:!0,passthrough:!1,errorMessage:e})}passthrough(){return new VldObject({...this._config,strict:!1,passthrough:!0})}loose(){return this.passthrough()}strip(){const e={...this._config,strict:!1,passthrough:!1};return delete e.catchall,new VldObject(e)}partial(){const s={};for(const t in this._config.shape)s[t]=new e.VldOptional(this._config.shape[t]);return new VldObject({...this._config,shape:s})}deepPartial(){const s={};for(const t in this._config.shape){const i=this._config.shape[t];s[t]=i instanceof VldObject?new e.VldOptional(i.deepPartial()):new e.VldOptional(i)}return new VldObject({...this._config,shape:s})}exactPartial(){const s={};for(const t in this._config.shape)s[t]=new e.VldExactOptional(this._config.shape[t]);return new VldObject({...this._config,shape:s})}pick(...e){const s={};let t=[];t=1!==e.length||"object"!=typeof e[0]||null===e[0]||Array.isArray(e[0])?e.flat():Object.keys(e[0]).filter(s=>e[0][s]);for(const e of t)e in this._config.shape&&(s[e]=this._config.shape[e]);return new VldObject({...this._config,shape:s})}omit(...e){let s;s=1!==e.length||"object"!=typeof e[0]||null===e[0]||Array.isArray(e[0])?new Set(e.flat()):new Set(Object.keys(e[0]).filter(s=>e[0][s]));const t={};for(const e in this._config.shape)s.has(e)||(t[e]=this._config.shape[e]);return new VldObject({...this._config,shape:t})}extend(e){return new VldObject({...this._config,shape:{...this._config.shape,...e}})}merge(e){return new VldObject({...this._config,shape:{...this._config.shape,...e.config.shape}})}required(){const s={};for(const t in this._config.shape){const i=this._config.shape[t];if(i instanceof e.VldOptional){const e=i.baseValidator;if(!e||"function"!=typeof e.parse)throw new Error(`Invalid VldOptional structure for field "${t}": missing or invalid baseValidator`);s[t]=e}else s[t]=i}return new VldObject({...this._config,shape:s})}catchall(e){return new VldObject({...this._config,catchall:e,passthrough:!1})}get shape(){return this._config.shape}keyof(){const e=Object.keys(this._config.shape);if(0===e.length)throw new Error("Cannot create keyof enum from empty object");return t.VldEnum.create(e)}safeExtend(e){const t=new Set(Object.keys(this._config.shape)),i=Object.keys(e),r=[];for(const e of i)t.has(e)&&r.push(e);if(r.length>0)throw new Error(`safeExtend: ${s.getMessages().safeExtendOverlap(r)}`);return new VldObject({...this._config,shape:{...this._config.shape,...e}})}}exports.VldObject=VldObject;
|
|
1
|
+
"use strict";var e=require("./base.cjs"),s=require("../locales/runtime.cjs"),t=require("./enum.cjs"),i=require("../chunks/security-aXZVI7qW.cjs"),r=require("../chunks/errors-core-C0mA6tfa.cjs");require("../registry.cjs"),require("../locales/en.cjs");class VldObject extends e.VldBase{createSafeParseError(e,t){if(e instanceof r.VldError)return void 0!==t?new r.VldError(e.issues.map(e=>({...e,path:e.path?[t,...e.path]:[t],message:e.message.startsWith("Invalid field")?e.message:s.getMessages().objectField(String(t),e.message)}))):e;const i=e instanceof Error?e.message:String(e);return new r.VldError([{code:"invalid_type",path:void 0!==t?[t]:[],message:void 0===t||i.startsWith("Invalid field")?i:s.getMessages().objectField(String(t),i)}])}constructor(s){super(e.VLD_VALIDATOR_TYPES.OBJECT),this._config=s,this._shapeKeys=Object.keys(s.shape),this._shapeKeysSet=new Set(this._shapeKeys),this._validators=this._shapeKeys.map(e=>this.tryGetFieldValidator(e)),this._validatorTypes=this._shapeKeys.map((e,s)=>this._validators[s]?.validatorType||this.getValidatorType(e)),this._simpleFieldModes=this._validators.map((e,s)=>this.getSimpleFieldMode(e,this._validatorTypes[s])),this._simpleFieldValues=this._validators.map((e,s)=>"literal"===this._simpleFieldModes[s]?e.literal:void 0),this._canUseSimpleObjectFastPath=!s.strict&&!s.passthrough&&!s.catchall&&this._shapeKeys.length>0&&this._simpleFieldModes.every(e=>void 0!==e),this._canUseSafeParseFastPath=this._validators.every(s=>s instanceof e.VldBase)&&(void 0===s.catchall||s.catchall instanceof e.VldBase)}tryGetFieldValidator(e){try{const s=Object.getOwnPropertyDescriptor(this._config.shape,e);if(s?.get)return;return this.resolveFieldValidator(e)}catch{return}}resolveFieldValidator(e){try{const s=this._config.shape[e];if(!s||"function"!=typeof s.safeParse)return;return s}catch{return}}getFieldValidator(e,s){const t=(void 0===s?void 0:this._validators[s])||this.resolveFieldValidator(e);if(!t)throw new Error(`Invalid validator for field "${e}"`);return t}getValidatorType(s){try{const t=this._config.shape[s];return t?.validatorType||e.VLD_VALIDATOR_TYPES.UNKNOWN}catch{return e.VLD_VALIDATOR_TYPES.UNKNOWN}}getSimpleFieldMode(s,t){if(s&&!0===s.isSimple)switch(t){case e.VLD_VALIDATOR_TYPES.STRING:return"string";case e.VLD_VALIDATOR_TYPES.NUMBER:return"number";case e.VLD_VALIDATOR_TYPES.BOOLEAN:return"boolean";case e.VLD_VALIDATOR_TYPES.BIGINT:return"bigint";case e.VLD_VALIDATOR_TYPES.SYMBOL:return"symbol";case e.VLD_VALIDATOR_TYPES.NULL:return"null";case e.VLD_VALIDATOR_TYPES.UNDEFINED:case e.VLD_VALIDATOR_TYPES.VOID:return"undefinedValue";case e.VLD_VALIDATOR_TYPES.LITERAL:return"literal";case e.VLD_VALIDATOR_TYPES.ANY:case e.VLD_VALIDATOR_TYPES.UNKNOWN:return"passthrough";default:return}}getSimpleFieldError(e,t,i){switch(e){case"string":return s.getMessages().invalidString;case"number":return s.getMessages().invalidNumber;case"boolean":return s.getMessages().invalidBoolean;case"bigint":return s.getMessages().invalidBigint;case"symbol":return s.getMessages().invalidSymbol;case"null":return"Expected null, received "+typeof i;case"undefinedValue":return s.getMessages().expectedUndefined;case"literal":return s.getMessages().literalExpected(JSON.stringify(t),JSON.stringify(i));default:return s.getMessages().invalidObject}}parseCheckedField(s,t,i){if(t===e.VLD_VALIDATOR_TYPES.STRING&&"string"==typeof i){const e=s.parseKnownString;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.NUMBER&&"number"==typeof i&&!isNaN(i)){const e=s.parseKnownNumber;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.BOOLEAN&&"boolean"==typeof i){const e=s.parseKnownBoolean;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.BIGINT&&"bigint"==typeof i){const e=s.parseKnownBigInt;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.SYMBOL&&"symbol"==typeof i){const e=s.parseKnownSymbol;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.FUNCTION&&"function"==typeof i){const e=s.parseKnownFunction;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.FILE&&"object"==typeof i&&null!==i&&("size"in i&&"type"in i||"undefined"!=typeof File&&i instanceof File)){const e=s.parseKnownFile;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.DATE&&i instanceof Date){const e=s.parseKnownDate;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.OBJECT&&"object"==typeof i&&null!==i&&!Array.isArray(i)){const e=s.parseKnownObject;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.ARRAY&&Array.isArray(i)){const e=s.parseKnownArray;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.TUPLE&&Array.isArray(i)){const e=s.parseKnownTuple;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.RECORD&&"object"==typeof i&&null!==i&&!Array.isArray(i)){const e=s.parseKnownRecord;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.SET&&i instanceof Set){const e=s.parseKnownSet;if("function"==typeof e)return e.call(s,i)}if(t===e.VLD_VALIDATOR_TYPES.MAP&&i instanceof Map){const e=s.parseKnownMap;if("function"==typeof e)return e.call(s,i)}return s.parse(i)}parseSimpleObjectValue(e,t,i=!1){if(2===this._shapeKeys.length&&"string"===this._simpleFieldModes[0]&&"number"===this._simpleFieldModes[1]){const t=this._shapeKeys[0],i=e[t];if("string"!=typeof i)throw new Error(s.getMessages().objectField(t,s.getMessages().invalidString));const r=this._shapeKeys[1],a=e[r];if("number"!=typeof a||isNaN(a))throw new Error(s.getMessages().objectField(r,s.getMessages().invalidNumber));const n={};return n[t]=i,n[r]=a,n}if(3===this._shapeKeys.length&&"literal"===this._simpleFieldModes[0]&&"string"===this._simpleFieldModes[1]&&"number"===this._simpleFieldModes[2]){const r=this._shapeKeys[0],a=e[r],n=this._simpleFieldValues[0];if((!i||r!==t)&&a!==n)throw new Error(s.getMessages().objectField(r,this.getSimpleFieldError("literal",n,a)));const o=this._shapeKeys[1],c=e[o];if("string"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidString));const l=this._shapeKeys[2],h=e[l];if("number"!=typeof h||isNaN(h))throw new Error(s.getMessages().objectField(l,s.getMessages().invalidNumber));const g={};return g[r]=n,g[o]=c,g[l]=h,g}const a={};for(let n=0;n<this._shapeKeys.length;n++){const o=this._shapeKeys[n],c=e[o],l=this._simpleFieldModes[n];switch(l){case"string":if("string"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidString));a[o]=c;break;case"number":if("number"!=typeof c||isNaN(c))throw new Error(s.getMessages().objectField(o,s.getMessages().invalidNumber));a[o]=c;break;case"boolean":if("boolean"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidBoolean));a[o]=c;break;case"bigint":if("bigint"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidBigint));a[o]=c;break;case"symbol":if("symbol"!=typeof c)throw new Error(s.getMessages().objectField(o,s.getMessages().invalidSymbol));a[o]=c;break;case"null":if(null!==c)throw new Error(s.getMessages().objectField(o,this.getSimpleFieldError(l,void 0,c)));a[o]=null;break;case"undefinedValue":if(!Object.prototype.hasOwnProperty.call(e,o))throw new r.VldError([{code:"invalid_type",path:[o],message:s.getMessages().objectField(o,s.getMessages().requiredField(o))}]);if(void 0!==c)throw new Error(s.getMessages().objectField(o,s.getMessages().expectedUndefined));a[o]=void 0;break;case"literal":if(i&&o===t){a[o]=this._simpleFieldValues[n];break}if(c!==this._simpleFieldValues[n])throw new Error(s.getMessages().objectField(o,this.getSimpleFieldError(l,this._simpleFieldValues[n],c)));a[o]=this._simpleFieldValues[n];break;case"passthrough":if(!Object.prototype.hasOwnProperty.call(e,o))throw new r.VldError([{code:"invalid_type",path:[o],message:s.getMessages().objectField(o,s.getMessages().requiredField(o))}]);a[o]=c;break;default:throw new Error(s.getMessages().objectField(o,s.getMessages().invalidObject))}}return a}get config(){return this._config}get shapeKeys(){return this._shapeKeys}get shapeKeysSet(){return this._shapeKeysSet}static create(e){return new VldObject({shape:e})}parse(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.parseObjectValue(e)}parseKnownObject(e,s){return this.parseObjectValue(e,s)}parseTrustedKnownObject(e,s){return this.parseObjectValue(e,s,!0)}parseObjectValue(e,t,a=!1){if(this._canUseSimpleObjectFastPath)return this.parseSimpleObjectValue(e,t,a);const n={};let o="";try{for(let i=0;i<this._shapeKeys.length;i++){if(o=this._shapeKeys[i],a&&o===t&&"literal"===this._simpleFieldModes[i]){n[o]=this._simpleFieldValues[i];continue}const r=this._simpleFieldModes[i];if(void 0!==r){const t=e[o];switch(r){case"string":if("string"!=typeof t)throw new Error(s.getMessages().invalidString);n[o]=t;continue;case"number":if("number"!=typeof t||isNaN(t))throw new Error(s.getMessages().invalidNumber);n[o]=t;continue;case"boolean":if("boolean"!=typeof t)throw new Error(s.getMessages().invalidBoolean);n[o]=t;continue;case"bigint":if("bigint"!=typeof t)throw new Error(s.getMessages().invalidBigint);n[o]=t;continue;case"symbol":if("symbol"!=typeof t)throw new Error(s.getMessages().invalidSymbol);n[o]=t;continue;case"null":if(null!==t)throw new Error(this.getSimpleFieldError(r,void 0,t));n[o]=null;continue;case"undefinedValue":if(!Object.prototype.hasOwnProperty.call(e,o))throw new Error(s.getMessages().objectField(o,s.getMessages().requiredField(o)));if(void 0!==t)throw new Error(s.getMessages().objectField(o,s.getMessages().expectedUndefined));n[o]=void 0;continue;case"literal":if(t!==this._simpleFieldValues[i])throw new Error(this.getSimpleFieldError(r,this._simpleFieldValues[i],t));n[o]=this._simpleFieldValues[i];continue;case"passthrough":if(!Object.prototype.hasOwnProperty.call(e,o))throw new Error(s.getMessages().objectField(o,s.getMessages().requiredField(o)));n[o]=t;continue}continue}const c=this.getFieldValidator(o,i);n[o]=this.parseCheckedField(c,this._validatorTypes[i],e[o])}}catch(e){if(e instanceof r.VldError)throw new r.VldError(e.issues.map(e=>({...e,path:e.path?[o,...e.path]:[o],message:s.getMessages().objectField(o,e.message.startsWith("Invalid field")?e.message.replace(/^Invalid field "[^"]+": /,""):e.message)})));const t=e instanceof Error?e.message:String(e);throw new r.VldError([{code:"invalid_type",path:[o],message:t.startsWith("Invalid field")?t:s.getMessages().objectField(o,t)}])}if(this._config.strict||this._config.passthrough||this._config.catchall){const t=Object.keys(e);if(this._config.strict){const e=[];for(let s=0;s<t.length;s++){const i=t[s];this._shapeKeysSet.has(i)||e.push(i)}if(e.length>0)throw new Error(s.getMessages().unexpectedKeys(e))}if(this._config.passthrough)for(let s=0;s<t.length;s++){const r=t[s];this._shapeKeysSet.has(r)||i.isDangerousKey(r)||(n[r]=e[r])}if(this._config.catchall)for(let r=0;r<t.length;r++){const a=t[r];if(!this._shapeKeysSet.has(a)&&!i.isDangerousKey(a))try{n[a]=this._config.catchall.parse(e[a])}catch(e){throw new Error(s.getMessages().objectField(a,e.message))}}}return n}safeParse(t){if("object"!=typeof t||null===t||Array.isArray(t))return{success:!1,error:this.createSafeParseError(this._config.errorMessage||s.getMessages().invalidObject)};const a=t;if(this._canUseSimpleObjectFastPath)try{return{success:!0,data:this.parseSimpleObjectValue(a)}}catch{}if(this._canUseSafeParseFastPath)try{return{success:!0,data:this.parseObjectValue(a)}}catch{}const n={},o=[];for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=a[i],c=this._simpleFieldModes[t];if(void 0!==c){if(("passthrough"===c||"undefinedValue"===c)&&!Object.prototype.hasOwnProperty.call(a,i)){o.push({code:"invalid_type",path:[i],message:s.getMessages().objectField(i,s.getMessages().requiredField(i))});continue}if("string"===c&&"string"==typeof r||"number"===c&&"number"==typeof r&&!isNaN(r)||"boolean"===c&&"boolean"==typeof r||"bigint"===c&&"bigint"==typeof r||"symbol"===c&&"symbol"==typeof r||"null"===c&&null===r||"undefinedValue"===c&&void 0===r||"literal"===c&&r===this._simpleFieldValues[t]||"passthrough"===c){n[i]="literal"===c?this._simpleFieldValues[t]:"null"===c?null:r;continue}o.push({code:"invalid_type",path:[i],message:s.getMessages().objectField(i,this.getSimpleFieldError(c,this._simpleFieldValues[t],r))});continue}let l;try{l=this.getFieldValidator(i,t)}catch(e){const s=this.createSafeParseError(e,i);o.push(...s.issues);continue}try{if(l instanceof e.VldBase)n[i]=this.parseCheckedField(l,this._validatorTypes[t],r);else{const e=l.safeParse(r);if(e.success)n[i]=e.data;else{const s=this.createSafeParseError(e.error,i);o.push(...s.issues)}}}catch(e){const s=this.createSafeParseError(e,i);o.push(...s.issues)}}if(this._config.strict||this._config.passthrough||this._config.catchall){const t=Object.keys(a);if(this._config.strict){const e=[];for(let s=0;s<t.length;s++){const i=t[s];this._shapeKeysSet.has(i)||e.push(i)}e.length>0&&o.push(...e.map(e=>({code:"unrecognized_keys",path:[e],message:s.getMessages().unexpectedKeys([e])})))}if(this._config.passthrough)for(let e=0;e<t.length;e++){const s=t[e];this._shapeKeysSet.has(s)||i.isDangerousKey(s)||(n[s]=a[s])}if(this._config.catchall){const s=this._config.catchall;for(let r=0;r<t.length;r++){const c=t[r];if(!this._shapeKeysSet.has(c)&&!i.isDangerousKey(c))try{if(s instanceof e.VldBase)n[c]=s.parse(a[c]);else{const e=s.safeParse(a[c]);if(e.success)n[c]=e.data;else{const s=this.createSafeParseError(e.error,c);o.push(...s.issues)}}}catch(e){const s=this.createSafeParseError(e,c);o.push(...s.issues)}}}}return o.length>0?{success:!1,error:new r.VldError(o)}:{success:!0,data:n}}encode(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.encodeObjectSync(e)}safeEncode(e){try{return{success:!0,data:this.encode(e)}}catch(e){return{success:!1,error:this.createSafeParseError(e.message)}}}async encodeAsync(e){if("object"!=typeof e||null===e||Array.isArray(e))throw new Error(this._config.errorMessage||s.getMessages().invalidObject);return this.encodeObjectAsync(e)}async safeEncodeAsync(e){try{return{success:!0,data:await this.encodeAsync(e)}}catch(e){return{success:!1,error:this.createSafeParseError(e.message)}}}encodeObjectSync(e){const s={};for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=this.getFieldValidator(i,t).encode(e[i]);(void 0!==r||Object.prototype.hasOwnProperty.call(e,i))&&(s[i]=r)}return this.encodeExtraKeysSync(e,s),s}async encodeObjectAsync(e){const s={};for(let t=0;t<this._shapeKeys.length;t++){const i=this._shapeKeys[t],r=await this.getFieldValidator(i,t).encodeAsync(e[i]);(void 0!==r||Object.prototype.hasOwnProperty.call(e,i))&&(s[i]=r)}const t=this.getEncodedExtraKeys(e);for(const r of t)i.isDangerousKey(r)||(this._config.catchall?s[r]=await this._config.catchall.encodeAsync(e[r]):this._config.passthrough&&(s[r]=e[r]));return s}getEncodedExtraKeys(e){const t=Object.keys(e).filter(e=>!this._shapeKeysSet.has(e));if(this._config.strict&&t.length>0)throw new Error(s.getMessages().unexpectedKeys(t));return t}encodeExtraKeysSync(e,s){for(const t of this.getEncodedExtraKeys(e))i.isDangerousKey(t)||(this._config.catchall?s[t]=this._config.catchall.encode(e[t]):this._config.passthrough&&(s[t]=e[t]))}strict(e){return new VldObject({...this._config,strict:!0,passthrough:!1,errorMessage:e})}passthrough(){return new VldObject({...this._config,strict:!1,passthrough:!0})}loose(){return this.passthrough()}strip(){const e={...this._config,strict:!1,passthrough:!1};return delete e.catchall,new VldObject(e)}partial(){const s={};for(const t in this._config.shape)s[t]=new e.VldOptional(this._config.shape[t]);return new VldObject({...this._config,shape:s})}deepPartial(){const s={};for(const t in this._config.shape){const i=this._config.shape[t];s[t]=i instanceof VldObject?new e.VldOptional(i.deepPartial()):new e.VldOptional(i)}return new VldObject({...this._config,shape:s})}exactPartial(){const s={};for(const t in this._config.shape)s[t]=new e.VldExactOptional(this._config.shape[t]);return new VldObject({...this._config,shape:s})}pick(...e){const s={};let t=[];t=1!==e.length||"object"!=typeof e[0]||null===e[0]||Array.isArray(e[0])?e.flat():Object.keys(e[0]).filter(s=>e[0][s]);for(const e of t)e in this._config.shape&&(s[e]=this._config.shape[e]);return new VldObject({...this._config,shape:s})}omit(...e){let s;s=1!==e.length||"object"!=typeof e[0]||null===e[0]||Array.isArray(e[0])?new Set(e.flat()):new Set(Object.keys(e[0]).filter(s=>e[0][s]));const t={};for(const e in this._config.shape)s.has(e)||(t[e]=this._config.shape[e]);return new VldObject({...this._config,shape:t})}extend(e){return new VldObject({...this._config,shape:{...this._config.shape,...e}})}merge(e){return new VldObject({...this._config,shape:{...this._config.shape,...e.config.shape}})}required(){const s={};for(const t in this._config.shape){const i=this._config.shape[t];if(i instanceof e.VldOptional){const e=i.baseValidator;if(!e||"function"!=typeof e.parse)throw new Error(`Invalid VldOptional structure for field "${t}": missing or invalid baseValidator`);s[t]=e}else s[t]=i}return new VldObject({...this._config,shape:s})}catchall(e){return new VldObject({...this._config,catchall:e,passthrough:!1})}get shape(){return this._config.shape}keyof(){const e=Object.keys(this._config.shape);if(0===e.length)throw new Error("Cannot create keyof enum from empty object");return t.VldEnum.create(e)}safeExtend(e){const t=new Set(Object.keys(this._config.shape)),i=Object.keys(e),r=[];for(const e of i)t.has(e)&&r.push(e);if(r.length>0)throw new Error(`safeExtend: ${s.getMessages().safeExtendOverlap(r)}`);return new VldObject({...this._config,shape:{...this._config.shape,...e}})}}exports.VldObject=VldObject;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./base.cjs");require("../registry.cjs"),require("../chunks/errors-core-C0mA6tfa.cjs");class VldPromise extends e.VldBase{constructor(s){super(e.VLD_VALIDATOR_TYPES.PROMISE),this.inner=s}get"~standard"(){return{version:1,vendor:"vld",validate:async e=>{const s=await this.safeParse(e);return s.success?{value:s.data}:{issues:[{message:s.error.message}]}},types:void 0}}_isThenable(e){return null!==e&&"function"==typeof e.then}unwrap(){return this.inner}async parse(e){if(!this._isThenable(e))throw new Error("Expected a Promise value");const s=await Promise.resolve(e);return this.inner.parseAsync?this.inner.parseAsync(s):this.inner.parse(s)}parseAsync(e){return this.parse(e)}safeParse(s){return this._isThenable(s)?(async()=>{try{const e=await Promise.resolve(s);if(this.inner.safeParseAsync)return await this.inner.safeParseAsync(e);const r=this.inner.safeParse(e);return r.success?{success:!0,data:r.data}:r}catch(s){return{success:!1,error:e.ensureVldError(s)}}})():Promise.resolve({success:!1,error:e.ensureVldError("Expected a Promise value")})}safeParseAsync(e){return this.safeParse(e)}}exports.VldPromise=VldPromise,exports.promise=function(e){return new VldPromise(e)};
|
|
1
|
+
"use strict";var e=require("./base.cjs");require("../registry.cjs"),require("../chunks/errors-core-C0mA6tfa.cjs");class VldPromise extends e.VldBase{constructor(s){super(e.VLD_VALIDATOR_TYPES.PROMISE),this.inner=s}get"~standard"(){return{version:1,vendor:"vld",validate:async e=>{const s=await this.safeParse(e);return s.success?{value:s.data}:{issues:[{message:s.error.message}]}},types:void 0}}_isThenable(e){return null!==e&&"function"==typeof e.then}unwrap(){return this.inner}async parse(e){if(!this._isThenable(e))throw new Error("Expected a Promise value");const s=await Promise.resolve(e);return this.inner.parseAsync?this.inner.parseAsync(s):this.inner.parse(s)}parseAsync(e){return this.parse(e)}safeParse(s){return this._isThenable(s)?(async()=>{try{const e=await Promise.resolve(s);if(this.inner.safeParseAsync)return await this.inner.safeParseAsync(e);const r=this.inner.safeParse(e);return r.success?{success:!0,data:r.data}:r}catch(s){return{success:!1,error:e.ensureVldError(s)}}})():Promise.resolve({success:!1,error:e.ensureVldError("Expected a Promise value")})}safeParseAsync(e){return this.safeParse(e)}validate(e){throw new Error("Promise schemas validate asynchronously; use validateAsync instead")}async validateAsync(e){return(await this.safeParseAsync(e)).success}}exports.VldPromise=VldPromise,exports.promise=function(e){return new VldPromise(e)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./base.cjs"),t=require("../locales/runtime.cjs"),r=require("../chunks/ip-validation-BZqPamPC.cjs"),a=require("../chunks/errors-core-C0mA6tfa.cjs");require("../registry.cjs"),require("../locales/en.cjs");const i="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function d(e,t){return e.lastIndex=0,e.test(t)}function s(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function o(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}function n(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"!=typeof e.precision?`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`:-1===e.precision?t:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`}function c(e){return void 0===e?/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/:new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)}const u={cuid:/^[cC][0-9a-z]{6,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid:/^[0-9a-vA-V]{20}$/,ksuid:/^[A-Za-z0-9]{27}$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,nanoidOfLength:e=>new RegExp(`^[a-zA-Z0-9_-]{${e}}$`),duration:/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,extendedDuration:/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,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})$/,creditCard:/^\d(?:[ -]?\d){11,18}$/,uuid:c,uuid4:c(4),uuid6:c(6),uuid7:c(7),email:/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+.-]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/,html5Email:/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,rfc5322Email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}))$/,unicodeEmail:/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,idnEmail:/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,browserEmail:/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,emoji:()=>/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6:/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,mac:function(e=":"){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},cidrv4:/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6:/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url:/^[A-Za-z0-9_-]*$/,hostname:/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,domain:/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,httpProtocol:/^https?$/,e164:/^\+[1-9]\d{6,14}$/,date:new RegExp(`^${i}$`),time:function(e={}){return new RegExp(`^${n(e)}$`)},datetime:function(e={}){const t=["Z"];return e.local&&t.push(""),e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),new RegExp(`^${i}T${n(e)}(?:${t.join("|")})$`)},string:function(e){const t=e?`[\\s\\S]{${e.minimum??0},${e.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bigint:/^-?\d+n?$/,integer:/^-?\d+$/,number:/^-?\d+(?:\.\d+)?$/,boolean:/^(?:true|false)$/i,null:/^null$/i,undefined:/^undefined$/i,lowercase:/^[^A-Z]*$/,uppercase:/^[^a-z]*$/,hex:/^[0-9a-fA-F]*$/,md5_hex:/^[0-9a-fA-F]{32}$/,md5_base64:s(22,"=="),md5_base64url:o(22),sha1_hex:/^[0-9a-fA-F]{40}$/,sha1_base64:s(27,"="),sha1_base64url:o(27),sha256_hex:/^[0-9a-fA-F]{64}$/,sha256_base64:s(43,"="),sha256_base64url:o(43),sha384_hex:/^[0-9a-fA-F]{96}$/,sha384_base64:s(64,""),sha384_base64url:o(64),sha512_hex:/^[0-9a-fA-F]{128}$/,sha512_base64:s(86,"=="),sha512_base64url:o(86),jwt:/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$/,httpUrl:/^https?:\/\/[^\s/$.?#].[^\s]*$/,md5:/^[a-f0-9]{32}$/i,sha1:/^[a-f0-9]{40}$/i,sha256:/^[a-f0-9]{64}$/i,sha384:/^[a-f0-9]{96}$/i,sha512:/^[a-f0-9]{128}$/i};class VldStringFormat extends e.VldBase{constructor(t,r,a,i=e=>e,d){super(e.VLD_VALIDATOR_TYPES.STRING_FORMAT),this._format=t,this._validator=r,this._errorMessage=a,this._normalize=i,this._patternSource=d}static create(e,t,r,a,i){return new VldStringFormat(e,t,r,a,i)}_createFormatIssue(){const e={code:"invalid_format",path:[],origin:"string",format:this._format,message:this._errorMessage||`Invalid ${this._format}`};return this._patternSource&&(e.pattern=this._patternSource),new a.VldError([e])}parse(e){if("string"!=typeof e)throw new a.VldError([a.createInvalidTypeIssue("string",a.getTypeName(e),t.getMessages().invalidString)]);if(!this._validator(e))throw this._createFormatIssue();return this._normalize(e)}safeParse(e){return"string"!=typeof e?{success:!1,error:new a.VldError([a.createInvalidTypeIssue("string",a.getTypeName(e),t.getMessages().invalidString)])}:this._validator(e)?{success:!0,data:this._normalize(e)}:{success:!1,error:this._createFormatIssue()}}}const l=/[ -]/g;function m(e){return!!u.creditCard.test(e)&&function(e){let t=0,r=!1;for(let a=e.length-1;a>=0;a--){let i=e.charCodeAt(a)-48;r&&(i*=2,i>9&&(i-=9)),t+=i,r=!r}return t%10==0}(e.replace(l,""))}const f={ZodISODate:VldStringFormat,ZodISODateTime:VldStringFormat,ZodISODuration:VldStringFormat,ZodISOTime:VldStringFormat,date:()=>VldStringFormat.create("date",e=>d(u.date,e)),time:(e={})=>{const t=u.time(e);return VldStringFormat.create("time",e=>d(t,e))},datetime:(e={})=>{const t=u.datetime(e);return VldStringFormat.create("datetime",e=>d(t,e))},dateTime:(e={local:!0})=>{const t=u.datetime(e);return VldStringFormat.create("datetime",e=>d(t,e))},duration:()=>VldStringFormat.create("duration",e=>d(u.duration,e))};exports.VldStringFormat=VldStringFormat,exports.base64=()=>VldStringFormat.create("base64",e=>d(u.base64,e)),exports.base64url=()=>VldStringFormat.create("base64url",e=>d(u.base64url,e)),exports.cidrv4=()=>VldStringFormat.create("cidrv4",e=>d(u.cidrv4,e)),exports.cidrv6=()=>VldStringFormat.create("cidrv6",e=>{const t=e.lastIndexOf("/");if(t<=0)return!1;const a=Number(e.slice(t+1));return Number.isInteger(a)&&a>=0&&a<=128&&r.isValidIPv6(e.slice(0,t))}),exports.creditCard=e=>VldStringFormat.create("credit_card",m,e?.message,void 0,u.creditCard.source),exports.cuid=()=>VldStringFormat.create("cuid",e=>d(u.cuid,e)),exports.cuid2=()=>VldStringFormat.create("cuid2",e=>d(u.cuid2,e)),exports.e164=()=>VldStringFormat.create("e164",e=>d(u.e164,e)),exports.email=e=>{const t=e?.pattern??u.email;return VldStringFormat.create("email",e=>d(t,e),void 0,void 0,t.source)},exports.emoji=()=>VldStringFormat.create("emoji",e=>d(u.emoji(),e)),exports.guid=()=>VldStringFormat.create("guid",e=>d(u.guid,e)),exports.hash=e=>VldStringFormat.create("hash",t=>u[e]?.test(t)??!1,`Invalid ${e} hash`),exports.hex=()=>VldStringFormat.create("hex",e=>d(u.hex,e)),exports.hostname=()=>VldStringFormat.create("hostname",e=>d(u.hostname,e)),exports.httpUrl=()=>VldStringFormat.create("httpUrl",e=>d(u.httpUrl,e)),exports.ipv4=()=>VldStringFormat.create("ipv4",e=>d(u.ipv4,e)),exports.ipv6=()=>VldStringFormat.create("ipv6",e=>d(u.ipv6,e)),exports.isValidCreditCard=m,exports.iso=f,exports.jwt=()=>VldStringFormat.create("jwt",e=>d(u.jwt,e)),exports.ksuid=()=>VldStringFormat.create("ksuid",e=>d(u.ksuid,e)),exports.mac=e=>{const t=u.mac(e?.delimiter);return VldStringFormat.create("mac",e=>d(t,e))},exports.nanoid=()=>VldStringFormat.create("nanoid",e=>d(u.nanoid,e)),exports.regexes=u,exports.stringFormat=(e,t)=>{const r=t instanceof RegExp?e=>d(t,e):t;return VldStringFormat.create(e,r)},exports.ulid=()=>VldStringFormat.create("ulid",e=>d(u.ulid,e)),exports.url=(e={})=>VldStringFormat.create("url",t=>{const r=(e=>{try{return new URL(e)}catch{return}})(t);return void 0!==r&&(!e.hostname||d(e.hostname,r.hostname))&&(!e.protocol||d(e.protocol,r.protocol.slice(0,-1)))},void 0,e.normalize?e=>new URL(e).href:void 0),exports.uuid=e=>{const t=c(void 0===e?.version?void 0:Number(e.version.slice(1)));return VldStringFormat.create("uuid",e=>d(t,e))},exports.uuidv4=()=>VldStringFormat.create("uuid",e=>d(u.uuid4,e)),exports.uuidv6=()=>VldStringFormat.create("uuid",e=>d(u.uuid6,e)),exports.uuidv7=()=>VldStringFormat.create("uuid",e=>d(u.uuid7,e)),exports.xid=()=>VldStringFormat.create("xid",e=>d(u.xid,e));
|
|
1
|
+
"use strict";var e=require("./base.cjs"),t=require("../locales/runtime.cjs"),r=require("../chunks/ip-validation-BZqPamPC.cjs"),a=require("../chunks/errors-core-C0mA6tfa.cjs");require("../registry.cjs"),require("../locales/en.cjs");const i="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function d(e,t){return e.lastIndex=0,e.test(t)}function o(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function s(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}function n(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"!=typeof e.precision?`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`:-1===e.precision?t:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`}function c(e){return void 0===e?/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/:new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)}const u={cuid:/^[cC][0-9a-z]{6,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,xid:/^[0-9a-vA-V]{20}$/,ksuid:/^[A-Za-z0-9]{27}$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,nanoidOfLength:e=>new RegExp(`^[a-zA-Z0-9_-]{${e}}$`),duration:/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,extendedDuration:/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,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})$/,iban:/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,currencyCode:/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,anyString:/^[\s\S]{0,}$/,creditCard:/^\d(?:[ -]?\d){11,18}$/,uuid:c,uuid4:c(4),uuid6:c(6),uuid7:c(7),email:/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+.-]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9-]*\.)+[A-Za-z]{2,}$/,html5Email:/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,rfc5322Email:/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}))$/,unicodeEmail:/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,idnEmail:/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,browserEmail:/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,emoji:()=>/^(?=[\s\S]*[\p{Extended_Pictographic}\p{Regional_Indicator}\u20E3])[\p{Extended_Pictographic}\p{Emoji_Component}]+$/u,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6:/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,mac:function(e=":"){const t=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},cidrv4:/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cidrv6:/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,base64url:/^[A-Za-z0-9_-]*$/,hostname:/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,domain:/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,httpProtocol:/^https?$/,e164:/^\+[1-9]\d{6,14}$/,date:new RegExp(`^${i}$`),time:function(e={}){return new RegExp(`^${n(e)}$`)},datetime:function(e={}){const t=["Z"];return e.local&&t.push(""),e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)"),new RegExp(`^${i}T${n(e)}(?:${t.join("|")})$`)},string:function(e){const t=e?`[\\s\\S]{${e.minimum??0},${e.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},bigint:/^-?\d+n?$/,integer:/^-?\d+$/,number:/^-?\d+(?:\.\d+)?$/,boolean:/^(?:true|false)$/i,null:/^null$/i,undefined:/^undefined$/i,lowercase:/^[^A-Z]*$/,uppercase:/^[^a-z]*$/,hex:/^[0-9a-fA-F]*$/,md5_hex:/^[0-9a-fA-F]{32}$/,md5_base64:o(22,"=="),md5_base64url:s(22),sha1_hex:/^[0-9a-fA-F]{40}$/,sha1_base64:o(27,"="),sha1_base64url:s(27),sha256_hex:/^[0-9a-fA-F]{64}$/,sha256_base64:o(43,"="),sha256_base64url:s(43),sha384_hex:/^[0-9a-fA-F]{96}$/,sha384_base64:o(64,""),sha384_base64url:s(64),sha512_hex:/^[0-9a-fA-F]{128}$/,sha512_base64:o(86,"=="),sha512_base64url:s(86),jwt:/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]*$/,httpUrl:/^https?:\/\/[^\s/$.?#].[^\s]*$/,md5:/^[a-f0-9]{32}$/i,sha1:/^[a-f0-9]{40}$/i,sha256:/^[a-f0-9]{64}$/i,sha384:/^[a-f0-9]{96}$/i,sha512:/^[a-f0-9]{128}$/i};class VldStringFormat extends e.VldBase{constructor(t,r,a,i=e=>e,d){super(e.VLD_VALIDATOR_TYPES.STRING_FORMAT),this._format=t,this._validator=r,this._errorMessage=a,this._normalize=i,this._patternSource=d}static create(e,t,r,a,i){return new VldStringFormat(e,t,r,a,i)}_createFormatIssue(){const e={code:"invalid_format",path:[],origin:"string",format:this._format,message:this._errorMessage||`Invalid ${this._format}`};return this._patternSource&&(e.pattern=this._patternSource),new a.VldError([e])}parse(e){if("string"!=typeof e)throw new a.VldError([a.createInvalidTypeIssue("string",a.getTypeName(e),t.getMessages().invalidString)]);if(!this._validator(e))throw this._createFormatIssue();return this._normalize(e)}safeParse(e){return"string"!=typeof e?{success:!1,error:new a.VldError([a.createInvalidTypeIssue("string",a.getTypeName(e),t.getMessages().invalidString)])}:this._validator(e)?{success:!0,data:this._normalize(e)}:{success:!1,error:this._createFormatIssue()}}}const l=/[ -]/g;function A(e){return!!u.creditCard.test(e)&&function(e){let t=0,r=!1;for(let a=e.length-1;a>=0;a--){let i=e.charCodeAt(a)-48;r&&(i*=2,i>9&&(i-=9)),t+=i,r=!r}return t%10==0}(e.replace(l,""))}function m(e){return!!u.iban.test(e)&&function(e){let t=0;const r=e.length;for(let a=4;a<r;a++){const r=e.charCodeAt(a);t=(r>=65?100*t+(r-55):10*t+(r-48))%97}for(let r=0;r<4;r++){const a=e.charCodeAt(r);t=(a>=65?100*t+(a-55):10*t+(a-48))%97}return 1===t}(e)}const f={ZodISODate:VldStringFormat,ZodISODateTime:VldStringFormat,ZodISODuration:VldStringFormat,ZodISOTime:VldStringFormat,date:()=>VldStringFormat.create("date",e=>d(u.date,e)),time:(e={})=>{const t=u.time(e);return VldStringFormat.create("time",e=>d(t,e))},datetime:(e={})=>{const t=u.datetime(e);return VldStringFormat.create("datetime",e=>d(t,e))},dateTime:(e={local:!0})=>{const t=u.datetime(e);return VldStringFormat.create("datetime",e=>d(t,e))},duration:()=>VldStringFormat.create("duration",e=>d(u.duration,e))};exports.VldStringFormat=VldStringFormat,exports.base64=()=>VldStringFormat.create("base64",e=>d(u.base64,e)),exports.base64Charset=/^[0-9a-zA-Z+/]*={0,2}$/,exports.base64url=()=>VldStringFormat.create("base64url",e=>d(u.base64url,e)),exports.base64urlCharset=/^[A-Za-z0-9_-]*$/,exports.cidrv4=()=>VldStringFormat.create("cidrv4",e=>d(u.cidrv4,e)),exports.cidrv6=()=>VldStringFormat.create("cidrv6",e=>{const t=e.lastIndexOf("/");if(t<=0)return!1;const a=Number(e.slice(t+1));return Number.isInteger(a)&&a>=0&&a<=128&&r.isValidIPv6(e.slice(0,t))}),exports.creditCard=e=>VldStringFormat.create("credit_card",A,e?.message,void 0,u.creditCard.source),exports.cuid=()=>VldStringFormat.create("cuid",e=>d(u.cuid,e)),exports.cuid2=()=>VldStringFormat.create("cuid2",e=>d(u.cuid2,e)),exports.currencyCode=e=>VldStringFormat.create("currency_code",e=>d(u.currencyCode,e),e?.message,void 0,u.currencyCode.source),exports.e164=()=>VldStringFormat.create("e164",e=>d(u.e164,e)),exports.email=e=>{const t=e?.pattern??u.email;return VldStringFormat.create("email",e=>d(t,e),void 0,void 0,t.source)},exports.emoji=()=>VldStringFormat.create("emoji",e=>d(u.emoji(),e)),exports.guid=()=>VldStringFormat.create("guid",e=>d(u.guid,e)),exports.hash=e=>VldStringFormat.create("hash",t=>u[e]?.test(t)??!1,`Invalid ${e} hash`),exports.hex=()=>VldStringFormat.create("hex",e=>d(u.hex,e)),exports.hostname=()=>VldStringFormat.create("hostname",e=>d(u.hostname,e)),exports.httpUrl=()=>VldStringFormat.create("httpUrl",e=>d(u.httpUrl,e)),exports.iban=e=>VldStringFormat.create("iban",m,e?.message,void 0,u.iban.source),exports.ipv4=()=>VldStringFormat.create("ipv4",e=>d(u.ipv4,e)),exports.ipv6=()=>VldStringFormat.create("ipv6",e=>d(u.ipv6,e)),exports.isValidCreditCard=A,exports.isValidIBAN=m,exports.iso=f,exports.jwt=()=>VldStringFormat.create("jwt",e=>d(u.jwt,e)),exports.ksuid=()=>VldStringFormat.create("ksuid",e=>d(u.ksuid,e)),exports.mac=e=>{const t=u.mac(e?.delimiter);return VldStringFormat.create("mac",e=>d(t,e))},exports.nanoid=()=>VldStringFormat.create("nanoid",e=>d(u.nanoid,e)),exports.regexes=u,exports.stringFormat=(e,t)=>{const r=t instanceof RegExp?e=>d(t,e):t;return VldStringFormat.create(e,r)},exports.ulid=()=>VldStringFormat.create("ulid",e=>d(u.ulid,e)),exports.url=(e={})=>VldStringFormat.create("url",t=>{const r=(e=>{try{return new URL(e)}catch{return}})(t);return void 0!==r&&(!e.hostname||d(e.hostname,r.hostname))&&(!e.protocol||d(e.protocol,r.protocol.slice(0,-1)))},void 0,e.normalize?e=>new URL(e).href:void 0),exports.uuid=e=>{const t=c(void 0===e?.version?void 0:Number(e.version.slice(1)));return VldStringFormat.create("uuid",e=>d(t,e))},exports.uuidv4=()=>VldStringFormat.create("uuid",e=>d(u.uuid4,e)),exports.uuidv6=()=>VldStringFormat.create("uuid",e=>d(u.uuid6,e)),exports.uuidv7=()=>VldStringFormat.create("uuid",e=>d(u.uuid7,e)),exports.xid=()=>VldStringFormat.create("xid",e=>d(u.xid,e));
|