@oxog/vld 2.2.5 → 2.2.7

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +242 -1125
  3. package/dist/chunks/errors-core-CerMg2rq.js +1 -0
  4. package/dist/cjs/chunks/errors-core-DrydF46s.cjs +1 -0
  5. package/dist/cjs/cli/bin.cjs +1 -1
  6. package/dist/cjs/codecs/index.cjs +1 -1
  7. package/dist/cjs/coercion/index.cjs +1 -1
  8. package/dist/cjs/errors.cjs +1 -1
  9. package/dist/cjs/index.cjs +1 -1
  10. package/dist/cjs/mini.cjs +1 -1
  11. package/dist/cjs/v3/index.cjs +1 -1
  12. package/dist/cjs/v4/core/index.cjs +1 -1
  13. package/dist/cjs/v4/index.cjs +1 -1
  14. package/dist/cjs/v4/mini/index.cjs +1 -1
  15. package/dist/cjs/v4-mini/index.cjs +1 -1
  16. package/dist/cjs/validators/any.cjs +1 -1
  17. package/dist/cjs/validators/array.cjs +1 -1
  18. package/dist/cjs/validators/base.cjs +1 -1
  19. package/dist/cjs/validators/base64.cjs +1 -1
  20. package/dist/cjs/validators/bigint.cjs +1 -1
  21. package/dist/cjs/validators/boolean.cjs +1 -1
  22. package/dist/cjs/validators/codec.cjs +1 -1
  23. package/dist/cjs/validators/custom.cjs +1 -1
  24. package/dist/cjs/validators/date.cjs +1 -1
  25. package/dist/cjs/validators/discriminated-union.cjs +1 -1
  26. package/dist/cjs/validators/enum.cjs +1 -1
  27. package/dist/cjs/validators/file.cjs +1 -1
  28. package/dist/cjs/validators/function.cjs +1 -1
  29. package/dist/cjs/validators/hex.cjs +1 -1
  30. package/dist/cjs/validators/index.cjs +1 -1
  31. package/dist/cjs/validators/intersection.cjs +1 -1
  32. package/dist/cjs/validators/json.cjs +1 -1
  33. package/dist/cjs/validators/lazy.cjs +1 -1
  34. package/dist/cjs/validators/literal.cjs +1 -1
  35. package/dist/cjs/validators/map.cjs +1 -1
  36. package/dist/cjs/validators/nan.cjs +1 -1
  37. package/dist/cjs/validators/never.cjs +1 -1
  38. package/dist/cjs/validators/null.cjs +1 -1
  39. package/dist/cjs/validators/number.cjs +1 -1
  40. package/dist/cjs/validators/object.cjs +1 -1
  41. package/dist/cjs/validators/promise.cjs +1 -1
  42. package/dist/cjs/validators/record.cjs +1 -1
  43. package/dist/cjs/validators/set.cjs +1 -1
  44. package/dist/cjs/validators/string-bool.cjs +1 -1
  45. package/dist/cjs/validators/string-formats.cjs +1 -1
  46. package/dist/cjs/validators/string.cjs +1 -1
  47. package/dist/cjs/validators/symbol.cjs +1 -1
  48. package/dist/cjs/validators/template-literal.cjs +1 -1
  49. package/dist/cjs/validators/tuple.cjs +1 -1
  50. package/dist/cjs/validators/uint8array.cjs +1 -1
  51. package/dist/cjs/validators/undefined.cjs +1 -1
  52. package/dist/cjs/validators/union.cjs +1 -1
  53. package/dist/cjs/validators/unknown.cjs +1 -1
  54. package/dist/cjs/validators/void.cjs +1 -1
  55. package/dist/cjs/validators/xor.cjs +1 -1
  56. package/dist/coercion/index.js +1 -1
  57. package/dist/errors-core.d.ts +12 -1
  58. package/dist/errors.js +1 -1
  59. package/dist/index.d.ts +68 -5
  60. package/dist/index.js +1 -1
  61. package/dist/v3/index.js +1 -1
  62. package/dist/v4/core/index.js +1 -1
  63. package/dist/v4/index.js +1 -1
  64. package/dist/v4/mini/index.js +1 -1
  65. package/dist/v4-mini/index.js +1 -1
  66. package/dist/validators/array.js +1 -1
  67. package/dist/validators/base.d.ts +147 -9
  68. package/dist/validators/base.js +1 -1
  69. package/dist/validators/base64.js +1 -1
  70. package/dist/validators/bigint.d.ts +7 -0
  71. package/dist/validators/bigint.js +1 -1
  72. package/dist/validators/boolean.js +1 -1
  73. package/dist/validators/codec.js +1 -1
  74. package/dist/validators/custom.d.ts +20 -10
  75. package/dist/validators/custom.js +1 -1
  76. package/dist/validators/date.d.ts +2 -0
  77. package/dist/validators/date.js +1 -1
  78. package/dist/validators/discriminated-union.d.ts +2 -0
  79. package/dist/validators/discriminated-union.js +1 -1
  80. package/dist/validators/enum.d.ts +8 -2
  81. package/dist/validators/enum.js +1 -1
  82. package/dist/validators/file.js +1 -1
  83. package/dist/validators/function.js +1 -1
  84. package/dist/validators/hex.js +1 -1
  85. package/dist/validators/intersection.js +1 -1
  86. package/dist/validators/json.js +1 -1
  87. package/dist/validators/literal.d.ts +1 -0
  88. package/dist/validators/literal.js +1 -1
  89. package/dist/validators/map.d.ts +7 -0
  90. package/dist/validators/map.js +1 -1
  91. package/dist/validators/nan.js +1 -1
  92. package/dist/validators/never.js +1 -1
  93. package/dist/validators/null.js +1 -1
  94. package/dist/validators/number.d.ts +5 -0
  95. package/dist/validators/number.js +1 -1
  96. package/dist/validators/object.d.ts +6 -0
  97. package/dist/validators/object.js +1 -1
  98. package/dist/validators/promise.d.ts +6 -7
  99. package/dist/validators/promise.js +1 -1
  100. package/dist/validators/record.d.ts +2 -0
  101. package/dist/validators/record.js +1 -1
  102. package/dist/validators/set.d.ts +5 -0
  103. package/dist/validators/set.js +1 -1
  104. package/dist/validators/string-bool.js +1 -1
  105. package/dist/validators/string-formats.js +1 -1
  106. package/dist/validators/string.d.ts +2 -0
  107. package/dist/validators/string.js +1 -1
  108. package/dist/validators/symbol.js +1 -1
  109. package/dist/validators/template-literal.js +1 -1
  110. package/dist/validators/tuple.js +1 -1
  111. package/dist/validators/uint8array.js +1 -1
  112. package/dist/validators/undefined.js +1 -1
  113. package/dist/validators/union.d.ts +1 -0
  114. package/dist/validators/union.js +1 -1
  115. package/dist/validators/void.js +1 -1
  116. package/dist/validators/xor.js +1 -1
  117. package/package.json +2 -1
  118. package/dist/chunks/errors-core-Cqi4-9ew.js +0 -1
  119. package/dist/cjs/chunks/errors-core-DKPohm9I.cjs +0 -1
package/dist/v4/index.js CHANGED
@@ -1 +1 @@
1
- export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,number,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../chunks/errors-core-Cqi4-9ew.js";export{VldIntersection,VldIntersection as ZodIntersection}from"../validators/intersection.js";export{VldAny as ZodAny}from"../validators/any.js";export{VldArray as ZodArray}from"../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat}from"../validators/bigint.js";export{VldBoolean as ZodBoolean}from"../validators/boolean.js";export{VldCodec as ZodCodec}from"../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodSuccess}from"../validators/custom.js";export{VldDate as ZodDate}from"../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion}from"../validators/discriminated-union.js";export{VldEnum as ZodEnum}from"../validators/enum.js";export{VldFile as ZodFile}from"../validators/file.js";export{VldFunction as ZodFunction}from"../validators/function.js";export{VldJson as ZodJSON}from"../validators/json.js";export{VldLazy as ZodLazy}from"../validators/lazy.js";export{VldLiteral as ZodLiteral}from"../validators/literal.js";export{VldMap as ZodMap}from"../validators/map.js";export{VldNan as ZodNaN}from"../validators/nan.js";export{VldNever as ZodNever}from"../validators/never.js";export{VldNull as ZodNull}from"../validators/null.js";export{VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../validators/number.js";export{VldObject as ZodObject}from"../validators/object.js";export{VldPromise as ZodPromise}from"../validators/promise.js";export{VldRecord as ZodRecord}from"../validators/record.js";export{VldSet as ZodSet}from"../validators/set.js";export{VldString as ZodString}from"../validators/string.js";export{VldSymbol as ZodSymbol}from"../validators/symbol.js";export{VldTemplateLiteral as ZodTemplateLiteral}from"../validators/template-literal.js";export{VldTuple as ZodTuple}from"../validators/tuple.js";export{VldUndefined as ZodUndefined}from"../validators/undefined.js";export{VldUnion as ZodUnion}from"../validators/union.js";export{VldUnknown as ZodUnknown}from"../validators/unknown.js";export{VldVoid as ZodVoid}from"../validators/void.js";export{VldXor as ZodXor}from"../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../locales/runtime.js";export{globalRegistry,registry}from"../registry.js";export{s as setLocaleAsync}from"../chunks/index-yjpbvFgw.js";const Z=(o,r)=>o.default("function"==typeof r?r():r);export{Z as _default};
1
+ export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,number,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../chunks/errors-core-CerMg2rq.js";export{VldIntersection,VldIntersection as ZodIntersection}from"../validators/intersection.js";export{VldAny as ZodAny}from"../validators/any.js";export{VldArray as ZodArray}from"../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat}from"../validators/bigint.js";export{VldBoolean as ZodBoolean}from"../validators/boolean.js";export{VldCodec as ZodCodec}from"../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodSuccess}from"../validators/custom.js";export{VldDate as ZodDate}from"../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion}from"../validators/discriminated-union.js";export{VldEnum as ZodEnum}from"../validators/enum.js";export{VldFile as ZodFile}from"../validators/file.js";export{VldFunction as ZodFunction}from"../validators/function.js";export{VldJson as ZodJSON}from"../validators/json.js";export{VldLazy as ZodLazy}from"../validators/lazy.js";export{VldLiteral as ZodLiteral}from"../validators/literal.js";export{VldMap as ZodMap}from"../validators/map.js";export{VldNan as ZodNaN}from"../validators/nan.js";export{VldNever as ZodNever}from"../validators/never.js";export{VldNull as ZodNull}from"../validators/null.js";export{VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../validators/number.js";export{VldObject as ZodObject}from"../validators/object.js";export{VldPromise as ZodPromise}from"../validators/promise.js";export{VldRecord as ZodRecord}from"../validators/record.js";export{VldSet as ZodSet}from"../validators/set.js";export{VldString as ZodString}from"../validators/string.js";export{VldSymbol as ZodSymbol}from"../validators/symbol.js";export{VldTemplateLiteral as ZodTemplateLiteral}from"../validators/template-literal.js";export{VldTuple as ZodTuple}from"../validators/tuple.js";export{VldUndefined as ZodUndefined}from"../validators/undefined.js";export{VldUnion as ZodUnion}from"../validators/union.js";export{VldUnknown as ZodUnknown}from"../validators/unknown.js";export{VldVoid as ZodVoid}from"../validators/void.js";export{VldXor as ZodXor}from"../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../locales/runtime.js";export{globalRegistry,registry}from"../registry.js";export{s as setLocaleAsync}from"../chunks/index-yjpbvFgw.js";const Z=(o,r)=>o.default("function"==typeof r?r():r);export{Z as _default};
@@ -1 +1 @@
1
- export{_default,catchall,extend,maximum,merge,minimum,omit,partial,pick,required,safeExtend}from"../../v4-mini/index.js";export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,number,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldBrand as ZodMiniBrand,VldCatch as ZodMiniCatch,VldDefault as ZodMiniDefault,VldExactOptional as ZodMiniExactOptional,VldRefine as ZodMiniNonOptional,VldNullable as ZodMiniNullable,VldOptional as ZodMiniOptional,VldPipe as ZodMiniPipe,VldPrefault as ZodMiniPrefault,VldReadonly as ZodMiniReadonly,VldTransform as ZodMiniTransform,VldBase as ZodMiniType,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../../chunks/errors-core-Cqi4-9ew.js";export{VldIntersection,VldIntersection as ZodIntersection,VldIntersection as ZodMiniIntersection}from"../../validators/intersection.js";export{VldAny as ZodAny,VldAny as ZodMiniAny}from"../../validators/any.js";export{VldArray as ZodArray,VldArray as ZodMiniArray}from"../../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodMiniBase64,VldStringFormat as ZodMiniBase64URL,VldStringFormat as ZodMiniCIDRv4,VldStringFormat as ZodMiniCIDRv6,VldStringFormat as ZodMiniCUID,VldStringFormat as ZodMiniCUID2,VldStringFormat as ZodMiniCreditCard,VldStringFormat as ZodMiniCustomStringFormat,VldStringFormat as ZodMiniE164,VldStringFormat as ZodMiniEmail,VldStringFormat as ZodMiniEmoji,VldStringFormat as ZodMiniGUID,VldStringFormat as ZodMiniIPv4,VldStringFormat as ZodMiniIPv6,VldStringFormat as ZodMiniISODate,VldStringFormat as ZodMiniISODateTime,VldStringFormat as ZodMiniISODuration,VldStringFormat as ZodMiniISOTime,VldStringFormat as ZodMiniJWT,VldStringFormat as ZodMiniKSUID,VldStringFormat as ZodMiniMAC,VldStringFormat as ZodMiniNanoID,VldStringFormat as ZodMiniStringFormat,VldStringFormat as ZodMiniULID,VldStringFormat as ZodMiniURL,VldStringFormat as ZodMiniUUID,VldStringFormat as ZodMiniXID,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat,VldBigInt as ZodMiniBigInt,VldBigInt as ZodMiniBigIntFormat}from"../../validators/bigint.js";export{VldBoolean as ZodBoolean,VldBoolean as ZodMiniBoolean}from"../../validators/boolean.js";export{VldCodec as ZodCodec,VldCodec as ZodMiniCodec}from"../../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodMiniCustom,VldCustom as ZodMiniSuccess,VldCustom as ZodSuccess}from"../../validators/custom.js";export{VldDate as ZodDate,VldDate as ZodMiniDate}from"../../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion,VldDiscriminatedUnion as ZodMiniDiscriminatedUnion}from"../../validators/discriminated-union.js";export{VldEnum as ZodEnum,VldEnum as ZodMiniEnum}from"../../validators/enum.js";export{VldFile as ZodFile,VldFile as ZodMiniFile}from"../../validators/file.js";export{VldFunction as ZodFunction,VldFunction as ZodMiniFunction}from"../../validators/function.js";export{VldJson as ZodJSON}from"../../validators/json.js";export{VldLazy as ZodLazy,VldLazy as ZodMiniLazy}from"../../validators/lazy.js";export{VldLiteral as ZodLiteral,VldLiteral as ZodMiniLiteral}from"../../validators/literal.js";export{VldMap as ZodMap,VldMap as ZodMiniMap}from"../../validators/map.js";export{VldNan as ZodMiniNaN,VldNan as ZodNaN}from"../../validators/nan.js";export{VldNever as ZodMiniNever,VldNever as ZodNever}from"../../validators/never.js";export{VldNull as ZodMiniNull,VldNull as ZodNull}from"../../validators/null.js";export{VldNumber as ZodMiniNumber,VldNumber as ZodMiniNumberFormat,VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../../validators/number.js";export{VldObject as ZodMiniObject,VldObject as ZodObject}from"../../validators/object.js";export{VldPromise as ZodMiniPromise,VldPromise as ZodPromise}from"../../validators/promise.js";export{VldRecord as ZodMiniRecord,VldRecord as ZodRecord}from"../../validators/record.js";export{VldSet as ZodMiniSet,VldSet as ZodSet}from"../../validators/set.js";export{VldString as ZodMiniString,VldString as ZodString}from"../../validators/string.js";export{VldSymbol as ZodMiniSymbol,VldSymbol as ZodSymbol}from"../../validators/symbol.js";export{VldTemplateLiteral as ZodMiniTemplateLiteral,VldTemplateLiteral as ZodTemplateLiteral}from"../../validators/template-literal.js";export{VldTuple as ZodMiniTuple,VldTuple as ZodTuple}from"../../validators/tuple.js";export{VldUndefined as ZodMiniUndefined,VldUndefined as ZodUndefined}from"../../validators/undefined.js";export{VldUnion as ZodMiniUnion,VldUnion as ZodUnion}from"../../validators/union.js";export{VldUnknown as ZodMiniUnknown,VldUnknown as ZodUnknown}from"../../validators/unknown.js";export{VldVoid as ZodMiniVoid,VldVoid as ZodVoid}from"../../validators/void.js";export{VldXor as ZodMiniXor,VldXor as ZodXor}from"../../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../../locales/runtime.js";export{globalRegistry,registry}from"../../registry.js";export{s as setLocaleAsync}from"../../chunks/index-yjpbvFgw.js";
1
+ export{_default,catchall,extend,maximum,merge,minimum,omit,partial,pick,required,safeExtend}from"../../v4-mini/index.js";export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,number,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldBrand as ZodMiniBrand,VldCatch as ZodMiniCatch,VldDefault as ZodMiniDefault,VldExactOptional as ZodMiniExactOptional,VldRefine as ZodMiniNonOptional,VldNullable as ZodMiniNullable,VldOptional as ZodMiniOptional,VldPipe as ZodMiniPipe,VldPrefault as ZodMiniPrefault,VldReadonly as ZodMiniReadonly,VldTransform as ZodMiniTransform,VldBase as ZodMiniType,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../../chunks/errors-core-CerMg2rq.js";export{VldIntersection,VldIntersection as ZodIntersection,VldIntersection as ZodMiniIntersection}from"../../validators/intersection.js";export{VldAny as ZodAny,VldAny as ZodMiniAny}from"../../validators/any.js";export{VldArray as ZodArray,VldArray as ZodMiniArray}from"../../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodMiniBase64,VldStringFormat as ZodMiniBase64URL,VldStringFormat as ZodMiniCIDRv4,VldStringFormat as ZodMiniCIDRv6,VldStringFormat as ZodMiniCUID,VldStringFormat as ZodMiniCUID2,VldStringFormat as ZodMiniCreditCard,VldStringFormat as ZodMiniCustomStringFormat,VldStringFormat as ZodMiniE164,VldStringFormat as ZodMiniEmail,VldStringFormat as ZodMiniEmoji,VldStringFormat as ZodMiniGUID,VldStringFormat as ZodMiniIPv4,VldStringFormat as ZodMiniIPv6,VldStringFormat as ZodMiniISODate,VldStringFormat as ZodMiniISODateTime,VldStringFormat as ZodMiniISODuration,VldStringFormat as ZodMiniISOTime,VldStringFormat as ZodMiniJWT,VldStringFormat as ZodMiniKSUID,VldStringFormat as ZodMiniMAC,VldStringFormat as ZodMiniNanoID,VldStringFormat as ZodMiniStringFormat,VldStringFormat as ZodMiniULID,VldStringFormat as ZodMiniURL,VldStringFormat as ZodMiniUUID,VldStringFormat as ZodMiniXID,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat,VldBigInt as ZodMiniBigInt,VldBigInt as ZodMiniBigIntFormat}from"../../validators/bigint.js";export{VldBoolean as ZodBoolean,VldBoolean as ZodMiniBoolean}from"../../validators/boolean.js";export{VldCodec as ZodCodec,VldCodec as ZodMiniCodec}from"../../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodMiniCustom,VldCustom as ZodMiniSuccess,VldCustom as ZodSuccess}from"../../validators/custom.js";export{VldDate as ZodDate,VldDate as ZodMiniDate}from"../../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion,VldDiscriminatedUnion as ZodMiniDiscriminatedUnion}from"../../validators/discriminated-union.js";export{VldEnum as ZodEnum,VldEnum as ZodMiniEnum}from"../../validators/enum.js";export{VldFile as ZodFile,VldFile as ZodMiniFile}from"../../validators/file.js";export{VldFunction as ZodFunction,VldFunction as ZodMiniFunction}from"../../validators/function.js";export{VldJson as ZodJSON}from"../../validators/json.js";export{VldLazy as ZodLazy,VldLazy as ZodMiniLazy}from"../../validators/lazy.js";export{VldLiteral as ZodLiteral,VldLiteral as ZodMiniLiteral}from"../../validators/literal.js";export{VldMap as ZodMap,VldMap as ZodMiniMap}from"../../validators/map.js";export{VldNan as ZodMiniNaN,VldNan as ZodNaN}from"../../validators/nan.js";export{VldNever as ZodMiniNever,VldNever as ZodNever}from"../../validators/never.js";export{VldNull as ZodMiniNull,VldNull as ZodNull}from"../../validators/null.js";export{VldNumber as ZodMiniNumber,VldNumber as ZodMiniNumberFormat,VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../../validators/number.js";export{VldObject as ZodMiniObject,VldObject as ZodObject}from"../../validators/object.js";export{VldPromise as ZodMiniPromise,VldPromise as ZodPromise}from"../../validators/promise.js";export{VldRecord as ZodMiniRecord,VldRecord as ZodRecord}from"../../validators/record.js";export{VldSet as ZodMiniSet,VldSet as ZodSet}from"../../validators/set.js";export{VldString as ZodMiniString,VldString as ZodString}from"../../validators/string.js";export{VldSymbol as ZodMiniSymbol,VldSymbol as ZodSymbol}from"../../validators/symbol.js";export{VldTemplateLiteral as ZodMiniTemplateLiteral,VldTemplateLiteral as ZodTemplateLiteral}from"../../validators/template-literal.js";export{VldTuple as ZodMiniTuple,VldTuple as ZodTuple}from"../../validators/tuple.js";export{VldUndefined as ZodMiniUndefined,VldUndefined as ZodUndefined}from"../../validators/undefined.js";export{VldUnion as ZodMiniUnion,VldUnion as ZodUnion}from"../../validators/union.js";export{VldUnknown as ZodMiniUnknown,VldUnknown as ZodUnknown}from"../../validators/unknown.js";export{VldVoid as ZodMiniVoid,VldVoid as ZodVoid}from"../../validators/void.js";export{VldXor as ZodMiniXor,VldXor as ZodXor}from"../../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../../locales/runtime.js";export{globalRegistry,registry}from"../../registry.js";export{s as setLocaleAsync}from"../../chunks/index-yjpbvFgw.js";
@@ -1 +1 @@
1
- import{number as Z}from"../index.js";export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldBrand as ZodMiniBrand,VldCatch as ZodMiniCatch,VldDefault as ZodMiniDefault,VldExactOptional as ZodMiniExactOptional,VldRefine as ZodMiniNonOptional,VldNullable as ZodMiniNullable,VldOptional as ZodMiniOptional,VldPipe as ZodMiniPipe,VldPrefault as ZodMiniPrefault,VldReadonly as ZodMiniReadonly,VldTransform as ZodMiniTransform,VldBase as ZodMiniType,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../chunks/errors-core-Cqi4-9ew.js";export{VldIntersection,VldIntersection as ZodIntersection,VldIntersection as ZodMiniIntersection}from"../validators/intersection.js";export{VldAny as ZodAny,VldAny as ZodMiniAny}from"../validators/any.js";export{VldArray as ZodArray,VldArray as ZodMiniArray}from"../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodMiniBase64,VldStringFormat as ZodMiniBase64URL,VldStringFormat as ZodMiniCIDRv4,VldStringFormat as ZodMiniCIDRv6,VldStringFormat as ZodMiniCUID,VldStringFormat as ZodMiniCUID2,VldStringFormat as ZodMiniCreditCard,VldStringFormat as ZodMiniCustomStringFormat,VldStringFormat as ZodMiniE164,VldStringFormat as ZodMiniEmail,VldStringFormat as ZodMiniEmoji,VldStringFormat as ZodMiniGUID,VldStringFormat as ZodMiniIPv4,VldStringFormat as ZodMiniIPv6,VldStringFormat as ZodMiniISODate,VldStringFormat as ZodMiniISODateTime,VldStringFormat as ZodMiniISODuration,VldStringFormat as ZodMiniISOTime,VldStringFormat as ZodMiniJWT,VldStringFormat as ZodMiniKSUID,VldStringFormat as ZodMiniMAC,VldStringFormat as ZodMiniNanoID,VldStringFormat as ZodMiniStringFormat,VldStringFormat as ZodMiniULID,VldStringFormat as ZodMiniURL,VldStringFormat as ZodMiniUUID,VldStringFormat as ZodMiniXID,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat,VldBigInt as ZodMiniBigInt,VldBigInt as ZodMiniBigIntFormat}from"../validators/bigint.js";export{VldBoolean as ZodBoolean,VldBoolean as ZodMiniBoolean}from"../validators/boolean.js";export{VldCodec as ZodCodec,VldCodec as ZodMiniCodec}from"../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodMiniCustom,VldCustom as ZodMiniSuccess,VldCustom as ZodSuccess}from"../validators/custom.js";export{VldDate as ZodDate,VldDate as ZodMiniDate}from"../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion,VldDiscriminatedUnion as ZodMiniDiscriminatedUnion}from"../validators/discriminated-union.js";export{VldEnum as ZodEnum,VldEnum as ZodMiniEnum}from"../validators/enum.js";export{VldFile as ZodFile,VldFile as ZodMiniFile}from"../validators/file.js";export{VldFunction as ZodFunction,VldFunction as ZodMiniFunction}from"../validators/function.js";export{VldJson as ZodJSON}from"../validators/json.js";export{VldLazy as ZodLazy,VldLazy as ZodMiniLazy}from"../validators/lazy.js";export{VldLiteral as ZodLiteral,VldLiteral as ZodMiniLiteral}from"../validators/literal.js";export{VldMap as ZodMap,VldMap as ZodMiniMap}from"../validators/map.js";export{VldNan as ZodMiniNaN,VldNan as ZodNaN}from"../validators/nan.js";export{VldNever as ZodMiniNever,VldNever as ZodNever}from"../validators/never.js";export{VldNull as ZodMiniNull,VldNull as ZodNull}from"../validators/null.js";export{VldNumber as ZodMiniNumber,VldNumber as ZodMiniNumberFormat,VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../validators/number.js";export{VldObject as ZodMiniObject,VldObject as ZodObject}from"../validators/object.js";export{VldPromise as ZodMiniPromise,VldPromise as ZodPromise}from"../validators/promise.js";export{VldRecord as ZodMiniRecord,VldRecord as ZodRecord}from"../validators/record.js";export{VldSet as ZodMiniSet,VldSet as ZodSet}from"../validators/set.js";export{VldString as ZodMiniString,VldString as ZodString}from"../validators/string.js";export{VldSymbol as ZodMiniSymbol,VldSymbol as ZodSymbol}from"../validators/symbol.js";export{VldTemplateLiteral as ZodMiniTemplateLiteral,VldTemplateLiteral as ZodTemplateLiteral}from"../validators/template-literal.js";export{VldTuple as ZodMiniTuple,VldTuple as ZodTuple}from"../validators/tuple.js";export{VldUndefined as ZodMiniUndefined,VldUndefined as ZodUndefined}from"../validators/undefined.js";export{VldUnion as ZodMiniUnion,VldUnion as ZodUnion}from"../validators/union.js";export{VldUnknown as ZodMiniUnknown,VldUnknown as ZodUnknown}from"../validators/unknown.js";export{VldVoid as ZodMiniVoid,VldVoid as ZodVoid}from"../validators/void.js";export{VldXor as ZodMiniXor,VldXor as ZodXor}from"../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../locales/runtime.js";export{globalRegistry,registry}from"../registry.js";export{s as setLocaleAsync}from"../chunks/index-yjpbvFgw.js";function S(o){return Object.keys(o).filter(a=>o[a])}function M(o){return"string"==typeof o?o:o?.message||o?.error}const F=(o,a)=>o.pick(...S(a)),I=(o,a)=>o.omit(...S(a)),T=o=>o.partial(),U=o=>o.required(),D=(o,a)=>o.extend(a),L=(o,a)=>o.safeExtend(a),E=(o,a)=>a&&"function"==typeof a.parse?o.merge(a):o.extend(a),N=(o,a)=>o.catchall(a),O=(o,a)=>o.default("function"==typeof a?a():a),R=(o,a)=>{const r=M(a);return Z().min(o,r)},P=(o,a)=>{const r=M(a);return Z().max(o,r)};export{O as _default,N as catchall,D as extend,P as maximum,E as merge,R as minimum,Z as number,I as omit,T as partial,F as pick,U as required,L as safeExtend};
1
+ import{number as Z}from"../index.js";export{$brand,$input,$output,NEVER,TimePrecision,ZodFirstPartyTypeKind,ZodIssueCode,_ZodString,_function,any,array,base64,base64Bytes,base64url,bigint,boolean,catch,check,cidrv4,cidrv6,clone,codec,coerce,config,core,createLogger,createNoOpLogger,creditCard,cuid,cuid2,custom,date,decode,decodeAsync,deepPartial,default,describe,disableLogging,discriminatedUnion,e164,email,emoji,enableDebug,encode,encodeAsync,endsWith,enum,exactOptional,file,float32,float64,formatError,fromJSONSchema,_function as function,getErrorMap,getLogger,gt,gte,guid,hash,hex,hexBytes,hostname,httpUrl,includes,initLogger,input,instanceof,int,int32,int64,intersection,ipv4,ipv6,iso,json,jwt,keyof,ksuid,lazy,length,literal,locales,looseObject,looseRecord,lowercase,lt,lte,mac,map,mapSchema,maxLength,maxSize,meta,mime,minLength,minSize,multipleOf,nan,nanoid,nativeEnum,negative,never,nonnegative,nonoptional,nonpositive,normalize,null,nullable,nullish,object,optional,output,overwrite,parse,parseAsync,partialRecord,pipe,positive,prefault,preprocess,promise,property,readonly,record,refine,regex,regexes,safeDecode,safeDecodeAsync,safeEncode,safeEncodeAsync,safeParse,safeParseAsync,set,setErrorMap,setLogLevel,size,slugify,startsWith,strictObject,string,stringFormat,stringbool,superRefine,symbol,templateLiteral,toJSONSchema,toLowerCase,toUpperCase,transform,trim,tuple,uint32,uint64,uint8Array,ulid,undefined,union,unknown,uppercase,url,util,uuid,uuidv4,uuidv6,uuidv7,default as v,void,xid,xor,z}from"../index.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"../compat/result.js";export{VldBase,VldMeta,VldBrand as ZodBranded,VldCatch as ZodCatch,VldDefault as ZodDefault,VldExactOptional as ZodExactOptional,VldMeta as ZodMeta,VldBrand as ZodMiniBrand,VldCatch as ZodMiniCatch,VldDefault as ZodMiniDefault,VldExactOptional as ZodMiniExactOptional,VldRefine as ZodMiniNonOptional,VldNullable as ZodMiniNullable,VldOptional as ZodMiniOptional,VldPipe as ZodMiniPipe,VldPrefault as ZodMiniPrefault,VldReadonly as ZodMiniReadonly,VldTransform as ZodMiniTransform,VldBase as ZodMiniType,VldRefine as ZodNonOptional,VldNullable as ZodNullable,VldOptional as ZodOptional,VldPipe as ZodPipe,VldPrefault as ZodPrefault,VldPreprocess as ZodPreprocess,VldReadonly as ZodReadonly,VldTransform as ZodTransform,VldBase as ZodType}from"../validators/base.js";export{V as VldError,V as ZodError,V as ZodRealError}from"../chunks/errors-core-CerMg2rq.js";export{VldIntersection,VldIntersection as ZodIntersection,VldIntersection as ZodMiniIntersection}from"../validators/intersection.js";export{VldAny as ZodAny,VldAny as ZodMiniAny}from"../validators/any.js";export{VldArray as ZodArray,VldArray as ZodMiniArray}from"../validators/array.js";export{VldStringFormat as ZodBase64,VldStringFormat as ZodBase64URL,VldStringFormat as ZodCIDRv4,VldStringFormat as ZodCIDRv6,VldStringFormat as ZodCUID,VldStringFormat as ZodCUID2,VldStringFormat as ZodCreditCard,VldStringFormat as ZodCustomStringFormat,VldStringFormat as ZodE164,VldStringFormat as ZodEmail,VldStringFormat as ZodEmoji,VldStringFormat as ZodGUID,VldStringFormat as ZodIPv4,VldStringFormat as ZodIPv6,VldStringFormat as ZodISODate,VldStringFormat as ZodISODateTime,VldStringFormat as ZodISODuration,VldStringFormat as ZodISOTime,VldStringFormat as ZodJWT,VldStringFormat as ZodKSUID,VldStringFormat as ZodMAC,VldStringFormat as ZodMiniBase64,VldStringFormat as ZodMiniBase64URL,VldStringFormat as ZodMiniCIDRv4,VldStringFormat as ZodMiniCIDRv6,VldStringFormat as ZodMiniCUID,VldStringFormat as ZodMiniCUID2,VldStringFormat as ZodMiniCreditCard,VldStringFormat as ZodMiniCustomStringFormat,VldStringFormat as ZodMiniE164,VldStringFormat as ZodMiniEmail,VldStringFormat as ZodMiniEmoji,VldStringFormat as ZodMiniGUID,VldStringFormat as ZodMiniIPv4,VldStringFormat as ZodMiniIPv6,VldStringFormat as ZodMiniISODate,VldStringFormat as ZodMiniISODateTime,VldStringFormat as ZodMiniISODuration,VldStringFormat as ZodMiniISOTime,VldStringFormat as ZodMiniJWT,VldStringFormat as ZodMiniKSUID,VldStringFormat as ZodMiniMAC,VldStringFormat as ZodMiniNanoID,VldStringFormat as ZodMiniStringFormat,VldStringFormat as ZodMiniULID,VldStringFormat as ZodMiniURL,VldStringFormat as ZodMiniUUID,VldStringFormat as ZodMiniXID,VldStringFormat as ZodNanoID,VldStringFormat as ZodStringFormat,VldStringFormat as ZodULID,VldStringFormat as ZodURL,VldStringFormat as ZodUUID,VldStringFormat as ZodXID}from"../validators/string-formats.js";export{VldBigInt as ZodBigInt,VldBigInt as ZodBigIntFormat,VldBigInt as ZodMiniBigInt,VldBigInt as ZodMiniBigIntFormat}from"../validators/bigint.js";export{VldBoolean as ZodBoolean,VldBoolean as ZodMiniBoolean}from"../validators/boolean.js";export{VldCodec as ZodCodec,VldCodec as ZodMiniCodec}from"../validators/codec.js";export{VldCustom as ZodCustom,VldCustom as ZodMiniCustom,VldCustom as ZodMiniSuccess,VldCustom as ZodSuccess}from"../validators/custom.js";export{VldDate as ZodDate,VldDate as ZodMiniDate}from"../validators/date.js";export{VldDiscriminatedUnion as ZodDiscriminatedUnion,VldDiscriminatedUnion as ZodMiniDiscriminatedUnion}from"../validators/discriminated-union.js";export{VldEnum as ZodEnum,VldEnum as ZodMiniEnum}from"../validators/enum.js";export{VldFile as ZodFile,VldFile as ZodMiniFile}from"../validators/file.js";export{VldFunction as ZodFunction,VldFunction as ZodMiniFunction}from"../validators/function.js";export{VldJson as ZodJSON}from"../validators/json.js";export{VldLazy as ZodLazy,VldLazy as ZodMiniLazy}from"../validators/lazy.js";export{VldLiteral as ZodLiteral,VldLiteral as ZodMiniLiteral}from"../validators/literal.js";export{VldMap as ZodMap,VldMap as ZodMiniMap}from"../validators/map.js";export{VldNan as ZodMiniNaN,VldNan as ZodNaN}from"../validators/nan.js";export{VldNever as ZodMiniNever,VldNever as ZodNever}from"../validators/never.js";export{VldNull as ZodMiniNull,VldNull as ZodNull}from"../validators/null.js";export{VldNumber as ZodMiniNumber,VldNumber as ZodMiniNumberFormat,VldNumber as ZodNumber,VldNumber as ZodNumberFormat}from"../validators/number.js";export{VldObject as ZodMiniObject,VldObject as ZodObject}from"../validators/object.js";export{VldPromise as ZodMiniPromise,VldPromise as ZodPromise}from"../validators/promise.js";export{VldRecord as ZodMiniRecord,VldRecord as ZodRecord}from"../validators/record.js";export{VldSet as ZodMiniSet,VldSet as ZodSet}from"../validators/set.js";export{VldString as ZodMiniString,VldString as ZodString}from"../validators/string.js";export{VldSymbol as ZodMiniSymbol,VldSymbol as ZodSymbol}from"../validators/symbol.js";export{VldTemplateLiteral as ZodMiniTemplateLiteral,VldTemplateLiteral as ZodTemplateLiteral}from"../validators/template-literal.js";export{VldTuple as ZodMiniTuple,VldTuple as ZodTuple}from"../validators/tuple.js";export{VldUndefined as ZodMiniUndefined,VldUndefined as ZodUndefined}from"../validators/undefined.js";export{VldUnion as ZodMiniUnion,VldUnion as ZodUnion}from"../validators/union.js";export{VldUnknown as ZodMiniUnknown,VldUnknown as ZodUnknown}from"../validators/unknown.js";export{VldVoid as ZodMiniVoid,VldVoid as ZodVoid}from"../validators/void.js";export{VldXor as ZodMiniXor,VldXor as ZodXor}from"../validators/xor.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"../chunks/index-CkbfQQ4n.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"../pigment.js";export{createEmitter,createEventBus,withEmitter}from"../compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"../kernel.js";export{flattenError,prettifyError,prettifyErrorColored,prettifyErrorPlain,treeifyError}from"../errors.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"../locales/runtime.js";export{globalRegistry,registry}from"../registry.js";export{s as setLocaleAsync}from"../chunks/index-yjpbvFgw.js";function S(o){return Object.keys(o).filter(a=>o[a])}function M(o){return"string"==typeof o?o:o?.message||o?.error}const F=(o,a)=>o.pick(...S(a)),I=(o,a)=>o.omit(...S(a)),T=o=>o.partial(),U=o=>o.required(),D=(o,a)=>o.extend(a),L=(o,a)=>o.safeExtend(a),E=(o,a)=>a&&"function"==typeof a.parse?o.merge(a):o.extend(a),N=(o,a)=>o.catchall(a),O=(o,a)=>o.default("function"==typeof a?a():a),R=(o,a)=>{const r=M(a);return Z().min(o,r)},P=(o,a)=>{const r=M(a);return Z().max(o,r)};export{O as _default,N as catchall,D as extend,P as maximum,E as merge,R as minimum,Z as number,I as omit,T as partial,F as pick,U as required,L as safeExtend};
@@ -1 +1 @@
1
- import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{getMessages as t}from"../locales/runtime.js";import{V as n,c as i,g as a}from"../chunks/errors-core-Cqi4-9ew.js";function s(e){return new n([{code:"invalid_array",path:[],message:e}])}function o(e,r){return new n([{code:"too_small",path:[],origin:"array",minimum:e,inclusive:!0,message:r}])}class VldArray extends e{constructor(e){super(r.ARRAY),this.config=e,this._simpleItemMode=this.getSimpleItemMode(e.itemValidator)}getSimpleItemMode(e){if(!0===e.isSimple)switch(e.validatorType){case r.STRING:return"string";case r.NUMBER:return"number";case r.BOOLEAN:return"boolean";default:return}}static create(e){return new VldArray({itemValidator:e})}get element(){return this.config.itemValidator}unwrap(){return this.config.itemValidator}parse(e){if(!Array.isArray(e)){const r=this.config.errorMessage||t().invalidArray;throw new n([i("array",a(e),r)])}return this.parseArrayValue(e)}parseKnownArray(e){return this.parseArrayValue(e)}parseArrayValue(e){if(void 0!==this.config.exactLength&&e.length!==this.config.exactLength)throw o(this.config.exactLength,this.config.errorMessage||t().arrayLength(this.config.exactLength));if(void 0!==this.config.minLength&&e.length<this.config.minLength)throw o(this.config.minLength,this.config.errorMessage||t().arrayMin(this.config.minLength));if(void 0!==this.config.maxLength&&e.length>this.config.maxLength)throw r=this.config.maxLength,i=this.config.errorMessage||t().arrayMax(this.config.maxLength),new n([{code:"too_big",path:[],origin:"array",maximum:r,inclusive:!0,message:i}]);var r,i;const a=e.length,s=new Array(a),c=this._simpleItemMode;if(void 0!==c){for(let r=0;r<a;r++){const n=e[r];switch(c){case"string":if("string"!=typeof n)throw new Error(t().arrayItem(r,t().invalidString));s[r]=n;break;case"number":if("number"!=typeof n||isNaN(n))throw new Error(t().arrayItem(r,t().invalidNumber));s[r]=n;break;case"boolean":if("boolean"!=typeof n)throw new Error(t().arrayItem(r,t().invalidBoolean));s[r]=n}}return this.config.unique&&this.checkUnique(s),s}for(let r=0;r<a;r++)try{s[r]=this.config.itemValidator.parse(e[r])}catch(e){const n=e instanceof Error?e.message:String(e);throw new Error(t().arrayItem(r,n))}return this.config.unique&&this.checkUnique(s),s}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return e instanceof n?{success:!1,error:e}:{success:!1,error:s(e.message)}}}encode(e){this.validateEncodedArray(e);const r=new Array(e.length);for(let t=0;t<e.length;t++)r[t]=this.config.itemValidator.encode(e[t]);return r}safeEncode(e){try{return{success:!0,data:this.encode(e)}}catch(e){return{success:!1,error:s(e.message)}}}async encodeAsync(e){this.validateEncodedArray(e);const r=new Array(e.length);for(let t=0;t<e.length;t++)r[t]=await this.config.itemValidator.encodeAsync(e[t]);return r}async safeEncodeAsync(e){try{return{success:!0,data:await this.encodeAsync(e)}}catch(e){return{success:!1,error:s(e.message)}}}validateEncodedArray(e){if(!Array.isArray(e))throw new Error(this.config.errorMessage||t().invalidArray);if(void 0!==this.config.exactLength&&e.length!==this.config.exactLength)throw new Error(this.config.errorMessage);if(void 0!==this.config.minLength&&e.length<this.config.minLength)throw new Error(this.config.errorMessage);if(void 0!==this.config.maxLength&&e.length>this.config.maxLength)throw new Error(this.config.errorMessage);this.config.unique&&this.checkUnique(e)}checkUnique(e){const r=new Set,t=new WeakMap;for(const n of e){let e;if("object"==typeof n&&null!==n){const r=t.get(n);if(void 0!==r)e=r;else{const r=this.stableStringify(n);e=r,t.set(n,r)}}else e=n;if(r.has(e))throw new Error("Array must contain unique items");r.add(e)}}stableStringify(e){const r=new WeakSet,t=(e,n=0)=>{if(n>100)return'"[Max Depth Exceeded]"';if(null===e)return"null";if(void 0===e)return"undefined";if("object"!=typeof e)return JSON.stringify(e);if(r.has(e))return'"[Circular]"';r.add(e);try{if(Array.isArray(e)){return`[${e.map(e=>t(e,n+1)).join(",")}]`}const r=Object.keys(e).sort();return`{${r.map(r=>`${JSON.stringify(r)}:${t(e[r],n+1)}`).join(",")}}`}finally{r.delete(e)}};try{return t(e)}catch{return String(e)}}min(e,r){return new VldArray({...this.config,minLength:e,errorMessage:r||t().arrayMin(e)})}max(e,r){return new VldArray({...this.config,maxLength:e,errorMessage:r||t().arrayMax(e)})}length(e,r){return new VldArray({...this.config,exactLength:e,minLength:void 0,maxLength:void 0,errorMessage:r||t().arrayLength(e)})}nonempty(e){return new VldArray({...this.config,minLength:1,errorMessage:e||t().arrayEmpty})}unique(e){return new VldArray({...this.config,unique:!0,errorMessage:e||"Array must contain unique items"})}between(e,r,t){return new VldArray({...this.config,minLength:e,maxLength:r,errorMessage:t||`Array length must be between ${e} and ${r}`})}}export{VldArray};
1
+ import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{getMessages as t}from"../locales/runtime.js";import{V as n,c as i,g as a}from"../chunks/errors-core-CerMg2rq.js";function s(e){return new n([{code:"invalid_array",path:[],message:e}])}function o(e,r){return new n([{code:"too_small",path:[],origin:"array",minimum:e,inclusive:!0,message:r}])}class VldArray extends e{constructor(e){super(r.ARRAY),this.config=e,this._simpleItemMode=this.getSimpleItemMode(e.itemValidator)}getSimpleItemMode(e){if(!0===e.isSimple)switch(e.validatorType){case r.STRING:return"string";case r.NUMBER:return"number";case r.BOOLEAN:return"boolean";default:return}}static create(e){return new VldArray({itemValidator:e})}get element(){return this.config.itemValidator}unwrap(){return this.config.itemValidator}parse(e){if(!Array.isArray(e)){const r=this.config.errorMessage||t().invalidArray;throw new n([i("array",a(e),r)])}return this.parseArrayValue(e)}parseKnownArray(e){return this.parseArrayValue(e)}parseArrayValue(e){if(void 0!==this.config.exactLength&&e.length!==this.config.exactLength)throw o(this.config.exactLength,this.config.errorMessage||t().arrayLength(this.config.exactLength));if(void 0!==this.config.minLength&&e.length<this.config.minLength)throw o(this.config.minLength,this.config.errorMessage||t().arrayMin(this.config.minLength));if(void 0!==this.config.maxLength&&e.length>this.config.maxLength)throw r=this.config.maxLength,i=this.config.errorMessage||t().arrayMax(this.config.maxLength),new n([{code:"too_big",path:[],origin:"array",maximum:r,inclusive:!0,message:i}]);var r,i;const a=e.length,s=new Array(a),c=this._simpleItemMode;if(void 0!==c){for(let r=0;r<a;r++){const n=e[r];switch(c){case"string":if("string"!=typeof n)throw new Error(t().arrayItem(r,t().invalidString));s[r]=n;break;case"number":if("number"!=typeof n||isNaN(n))throw new Error(t().arrayItem(r,t().invalidNumber));s[r]=n;break;case"boolean":if("boolean"!=typeof n)throw new Error(t().arrayItem(r,t().invalidBoolean));s[r]=n}}return this.config.unique&&this.checkUnique(s),s}for(let r=0;r<a;r++)try{s[r]=this.config.itemValidator.parse(e[r])}catch(e){const n=e instanceof Error?e.message:String(e);throw new Error(t().arrayItem(r,n))}return this.config.unique&&this.checkUnique(s),s}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return e instanceof n?{success:!1,error:e}:{success:!1,error:s(e.message)}}}encode(e){this.validateEncodedArray(e);const r=new Array(e.length);for(let t=0;t<e.length;t++)r[t]=this.config.itemValidator.encode(e[t]);return r}safeEncode(e){try{return{success:!0,data:this.encode(e)}}catch(e){return{success:!1,error:s(e.message)}}}async encodeAsync(e){this.validateEncodedArray(e);const r=new Array(e.length);for(let t=0;t<e.length;t++)r[t]=await this.config.itemValidator.encodeAsync(e[t]);return r}async safeEncodeAsync(e){try{return{success:!0,data:await this.encodeAsync(e)}}catch(e){return{success:!1,error:s(e.message)}}}validateEncodedArray(e){if(!Array.isArray(e))throw new Error(this.config.errorMessage||t().invalidArray);if(void 0!==this.config.exactLength&&e.length!==this.config.exactLength)throw new Error(this.config.errorMessage);if(void 0!==this.config.minLength&&e.length<this.config.minLength)throw new Error(this.config.errorMessage);if(void 0!==this.config.maxLength&&e.length>this.config.maxLength)throw new Error(this.config.errorMessage);this.config.unique&&this.checkUnique(e)}checkUnique(e){const r=new Set,t=new WeakMap;for(const n of e){let e;if("object"==typeof n&&null!==n){const r=t.get(n);if(void 0!==r)e=r;else{const r=this.stableStringify(n);e=r,t.set(n,r)}}else e=n;if(r.has(e))throw new Error("Array must contain unique items");r.add(e)}}stableStringify(e){const r=new WeakSet,t=(e,n=0)=>{if(n>100)return'"[Max Depth Exceeded]"';if(null===e)return"null";if(void 0===e)return"undefined";if("object"!=typeof e)return JSON.stringify(e);if(r.has(e))return'"[Circular]"';r.add(e);try{if(Array.isArray(e)){return`[${e.map(e=>t(e,n+1)).join(",")}]`}const r=Object.keys(e).sort();return`{${r.map(r=>`${JSON.stringify(r)}:${t(e[r],n+1)}`).join(",")}}`}finally{r.delete(e)}};try{return t(e)}catch{return String(e)}}min(e,r){return new VldArray({...this.config,minLength:e,errorMessage:r||t().arrayMin(e)})}max(e,r){return new VldArray({...this.config,maxLength:e,errorMessage:r||t().arrayMax(e)})}length(e,r){return new VldArray({...this.config,exactLength:e,minLength:void 0,maxLength:void 0,errorMessage:r||t().arrayLength(e)})}nonempty(e){return new VldArray({...this.config,minLength:1,errorMessage:e||t().arrayEmpty})}unique(e){return new VldArray({...this.config,unique:!0,errorMessage:e||"Array must contain unique items"})}between(e,r,t){return new VldArray({...this.config,minLength:e,maxLength:r,errorMessage:t||`Array length must be between ${e} and ${r}`})}}export{VldArray};
@@ -1,14 +1,29 @@
1
1
  import type { SchemaRegistry } from '../registry.js';
2
+ import { VldError } from '../errors-core.js';
2
3
  /**
3
4
  * Base result type for validation
4
5
  */
5
6
  export type ParseResult<T> = {
6
7
  readonly success: true;
7
8
  readonly data: T;
9
+ readonly error?: undefined;
8
10
  } | {
9
11
  readonly success: false;
10
- readonly error: Error;
12
+ readonly error: VldError;
13
+ readonly data?: undefined;
11
14
  };
15
+ export type SafeParseSuccess<T> = {
16
+ readonly success: true;
17
+ readonly data: T;
18
+ readonly error?: undefined;
19
+ };
20
+ export type SafeParseError<_T = unknown> = {
21
+ readonly success: false;
22
+ readonly error: VldError;
23
+ readonly data?: undefined;
24
+ };
25
+ export type SafeParseReturnType<_Input, Output> = SafeParseSuccess<Output> | SafeParseError<_Input>;
26
+ export declare function ensureVldError(error: unknown): VldError;
12
27
  export interface StandardTypedV1<Input = unknown, Output = Input> {
13
28
  readonly '~standard': StandardTypedV1Props<Input, Output>;
14
29
  }
@@ -112,12 +127,15 @@ export declare const VLD_VALIDATOR_TYPES: {
112
127
  };
113
128
  export type ValidatorType = typeof VLD_VALIDATOR_TYPES[keyof typeof VLD_VALIDATOR_TYPES];
114
129
  /**
115
- * Context for superRefine - allows adding multiple issues
130
+ * Context for superRefine - allows adding multiple issues with path and code
116
131
  */
117
132
  export interface SuperRefineContext {
118
133
  addIssue(issue: {
119
134
  message: string;
120
135
  code?: string;
136
+ path?: (string | number)[];
137
+ fatal?: boolean;
138
+ [key: string]: any;
121
139
  }): void;
122
140
  path: (string | number)[];
123
141
  }
@@ -126,6 +144,7 @@ export interface CheckPayload<T> {
126
144
  issues: Array<{
127
145
  message?: string;
128
146
  code?: string;
147
+ path?: (string | number)[];
129
148
  }>;
130
149
  aborted?: boolean;
131
150
  }
@@ -134,16 +153,25 @@ export type VldCheck<T> = ((payload: CheckPayload<T>) => void | Promise<void>) |
134
153
  check?: (payload: CheckPayload<T>) => void | Promise<void>;
135
154
  };
136
155
  };
156
+ export type CustomErrorParams = {
157
+ message?: string;
158
+ path?: (string | number)[];
159
+ params?: {
160
+ [k: string]: any;
161
+ };
162
+ fatal?: boolean;
163
+ };
137
164
  export type ErrorMap = (issue: {
138
165
  code?: string;
139
166
  input?: unknown;
140
167
  path?: (string | number)[];
141
168
  }) => string | undefined;
142
- export type ErrorParam = string | {
169
+ export type ErrorParam = string | CustomErrorParams | ((value: any) => CustomErrorParams | string) | {
143
170
  error?: string | ErrorMap;
144
171
  message?: string;
145
172
  };
146
173
  export declare function resolveErrorMessage(error: ErrorParam | undefined, fallback: string): string;
174
+ export declare function isPromiseLike<T = unknown>(value: unknown): value is PromiseLike<T>;
147
175
  type ValueOrFactory<T> = T | (() => T);
148
176
  interface SchemaCompositionFactories {
149
177
  array<TInput, TOutput>(schema: VldBase<TInput, TOutput>): VldBase<unknown[], TOutput[]>;
@@ -167,6 +195,10 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
167
195
  * @param validatorType The runtime type identifier
168
196
  */
169
197
  constructor(validatorType?: ValidatorType);
198
+ get type(): string;
199
+ get _def(): any;
200
+ get def(): any;
201
+ get _zod(): any;
170
202
  get '~standard'(): StandardSchemaV1Props<unknown, TOutput>;
171
203
  /**
172
204
  * Parse and validate a value, throwing an error if invalid
@@ -223,8 +255,8 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
223
255
  * @param message Optional custom error message
224
256
  * @returns A new refined validator
225
257
  */
226
- refine<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: string): VldRefine<TInput, TOutput, TRefined>;
227
- refine(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: string): VldRefine<TInput, TOutput, TOutput>;
258
+ refine<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: ErrorParam | CustomErrorParams | ((val: TOutput) => CustomErrorParams | string)): VldRefine<TInput, TOutput, TRefined>;
259
+ refine(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: ErrorParam | CustomErrorParams | ((val: TOutput) => CustomErrorParams | string)): VldRefine<TInput, TOutput, TOutput>;
228
260
  /**
229
261
  * Advanced refinement with context for adding multiple issues
230
262
  * @param refinement The refinement function with context
@@ -324,8 +356,8 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
324
356
  * @param message Optional custom error message
325
357
  * @returns A new refined validator
326
358
  */
327
- check<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: string): VldRefine<TInput, TOutput, TRefined>;
328
- check(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: string): VldRefine<TInput, TOutput, TOutput>;
359
+ check<TRefined extends TOutput>(predicate: (value: TOutput) => value is TRefined, message?: ErrorParam | CustomErrorParams | ((val: TOutput) => CustomErrorParams | string)): VldRefine<TInput, TOutput, TRefined>;
360
+ check(predicate: (value: TOutput) => boolean | Promise<boolean>, message?: ErrorParam | CustomErrorParams | ((val: TOutput) => CustomErrorParams | string)): VldRefine<TInput, TOutput, TOutput>;
329
361
  /**
330
362
  * Get metadata for this schema
331
363
  * Zod 4 API parity - allows attaching OpenAPI/JSON Schema metadata
@@ -339,6 +371,11 @@ export declare abstract class VldBase<TInput, TOutput = TInput> {
339
371
  * @returns A new validator with the metadata
340
372
  */
341
373
  meta(data: Partial<SchemaMetadata>): VldMeta<TInput, TOutput>;
374
+ /**
375
+ * Get or set metadata for this schema
376
+ */
377
+ meta(): SchemaMetadata | undefined;
378
+ meta(data: Partial<SchemaMetadata>): VldMeta<TInput, TOutput>;
342
379
  /**
343
380
  * Register this schema in a metadata registry and return the same instance.
344
381
  * This mirrors Zod 4's registry convenience API without changing validator
@@ -416,11 +453,63 @@ export declare class VldBrand<TInput, TOutput, TBrand extends string> extends Vl
416
453
  export declare class VldRefine<TInput, TBase, TOutput extends TBase = TBase> extends VldBase<TInput, TOutput> {
417
454
  private readonly baseValidator;
418
455
  private readonly predicate;
419
- private readonly customMessage?;
420
- constructor(baseValidator: VldBase<TInput, TBase>, predicate: (value: TBase) => boolean | Promise<boolean>, customMessage?: string | undefined);
456
+ private readonly customMessage;
457
+ private readonly refinePath?;
458
+ constructor(baseValidator: VldBase<TInput, TBase>, predicate: (value: TBase) => boolean | Promise<boolean>, customMessage?: ErrorParam | CustomErrorParams | ((val: TBase) => CustomErrorParams | string));
459
+ private _createIssue;
421
460
  parse(value: unknown): TOutput;
422
461
  safeParse(value: unknown): ParseResult<TOutput>;
423
462
  parseAsync(value: unknown): Promise<TOutput>;
463
+ safeParseAsync(value: unknown): Promise<ParseResult<TOutput>>;
464
+ private _wrap;
465
+ min(length: number | Date | bigint | any, message?: ErrorParam): this;
466
+ max(length: number | Date | bigint | any, message?: ErrorParam): this;
467
+ length(length: number, message?: ErrorParam): this;
468
+ email(message?: ErrorParam): this;
469
+ url(message?: ErrorParam): this;
470
+ uuid(message?: ErrorParam): this;
471
+ regex(pattern: RegExp, message?: ErrorParam): this;
472
+ startsWith(str: string, message?: ErrorParam): this;
473
+ endsWith(str: string, message?: ErrorParam): this;
474
+ includes(str: string, message?: ErrorParam): this;
475
+ ip(message?: ErrorParam): this;
476
+ ipv4(message?: ErrorParam): this;
477
+ ipv6(message?: ErrorParam): this;
478
+ nonempty(message?: ErrorParam): this;
479
+ trim(): this;
480
+ toLowerCase(): this;
481
+ lowercase(): this;
482
+ toUpperCase(): this;
483
+ uppercase(): this;
484
+ positive(message?: ErrorParam): this;
485
+ negative(message?: ErrorParam): this;
486
+ nonnegative(message?: ErrorParam): this;
487
+ nonpositive(message?: ErrorParam): this;
488
+ int(message?: ErrorParam): this;
489
+ finite(message?: ErrorParam): this;
490
+ safe(message?: ErrorParam): this;
491
+ multipleOf(value: number, message?: ErrorParam): this;
492
+ step(value: number, message?: ErrorParam): this;
493
+ gt(value: any, message?: ErrorParam): this;
494
+ gte(value: any, message?: ErrorParam): this;
495
+ lt(value: any, message?: ErrorParam): this;
496
+ lte(value: any, message?: ErrorParam): this;
497
+ extend<U extends Record<string, any>>(extension: {
498
+ [K in keyof U]: VldBase<unknown, U[K]>;
499
+ }): any;
500
+ merge(other: any): any;
501
+ pick<K extends keyof TOutput>(...keys: K[]): any;
502
+ omit<K extends keyof TOutput>(...keys: K[]): any;
503
+ partial(): any;
504
+ required(): any;
505
+ strict(message?: ErrorParam): this;
506
+ passthrough(): this;
507
+ strip(): this;
508
+ catchall(validator: any): this;
509
+ get shape(): any;
510
+ get keyof(): any;
511
+ unwrap(): any;
512
+ get element(): any;
424
513
  }
425
514
  /**
426
515
  * Transform validator - transforms data after validation
@@ -552,6 +641,55 @@ export declare class VldSuperRefine<TInput, TOutput> extends VldBase<TInput, TOu
552
641
  safeParse(value: unknown): ParseResult<TOutput>;
553
642
  parseAsync(value: unknown): Promise<TOutput>;
554
643
  safeParseAsync(value: unknown): Promise<ParseResult<TOutput>>;
644
+ private _wrap;
645
+ min(length: number | Date | bigint | any, message?: ErrorParam): this;
646
+ max(length: number | Date | bigint | any, message?: ErrorParam): this;
647
+ length(length: number, message?: ErrorParam): this;
648
+ email(message?: ErrorParam): this;
649
+ url(message?: ErrorParam): this;
650
+ uuid(message?: ErrorParam): this;
651
+ regex(pattern: RegExp, message?: ErrorParam): this;
652
+ startsWith(str: string, message?: ErrorParam): this;
653
+ endsWith(str: string, message?: ErrorParam): this;
654
+ includes(str: string, message?: ErrorParam): this;
655
+ ip(message?: ErrorParam): this;
656
+ ipv4(message?: ErrorParam): this;
657
+ ipv6(message?: ErrorParam): this;
658
+ nonempty(message?: ErrorParam): this;
659
+ trim(): this;
660
+ toLowerCase(): this;
661
+ lowercase(): this;
662
+ toUpperCase(): this;
663
+ uppercase(): this;
664
+ positive(message?: ErrorParam): this;
665
+ negative(message?: ErrorParam): this;
666
+ nonnegative(message?: ErrorParam): this;
667
+ nonpositive(message?: ErrorParam): this;
668
+ int(message?: ErrorParam): this;
669
+ finite(message?: ErrorParam): this;
670
+ safe(message?: ErrorParam): this;
671
+ multipleOf(value: number, message?: ErrorParam): this;
672
+ step(value: number, message?: ErrorParam): this;
673
+ gt(value: any, message?: ErrorParam): this;
674
+ gte(value: any, message?: ErrorParam): this;
675
+ lt(value: any, message?: ErrorParam): this;
676
+ lte(value: any, message?: ErrorParam): this;
677
+ extend<U extends Record<string, any>>(extension: {
678
+ [K in keyof U]: VldBase<unknown, U[K]>;
679
+ }): any;
680
+ merge(other: any): any;
681
+ pick<K extends keyof TOutput>(...keys: K[]): any;
682
+ omit<K extends keyof TOutput>(...keys: K[]): any;
683
+ partial(): any;
684
+ required(): any;
685
+ strict(message?: ErrorParam): this;
686
+ passthrough(): this;
687
+ strip(): this;
688
+ catchall(validator: any): this;
689
+ get shape(): any;
690
+ get keyof(): any;
691
+ unwrap(): any;
692
+ get element(): any;
555
693
  }
556
694
  /**
557
695
  * Preprocess validator - transforms input before validation
@@ -1 +1 @@
1
- import{globalRegistry as e}from"../registry.js";const s={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 r(e,s){return"string"==typeof e?e:"string"==typeof e?.error?e.error:"function"==typeof e?.error?e.error({})||s:"string"==typeof e?.message?e.message:s}function t(e){return null!==e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}let a;function n(e){a=e}function i(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 s=Object.getPrototypeOf(e);if(s===Object.prototype||null===s)return{...e}}return e}(e)}function o(e){if(!0===e.isSimple)switch(e.validatorType){case s.STRING:return"string";case s.NUMBER:return"number";case s.BOOLEAN:return"boolean";case s.BIGINT:return"bigint";case s.SYMBOL:return"symbol";default:return}}function c(e,s){switch(e){case"string":return"string"==typeof s?s:void 0;case"number":return"number"!=typeof s||isNaN(s)?void 0:s;case"boolean":return"boolean"==typeof s?s:void 0;case"bigint":return"bigint"==typeof s?s:void 0;case"symbol":return"symbol"==typeof s?s:void 0;default:return}}class VldBase{constructor(e="unknown"){this.validatorType=e}get"~standard"(){return{version:1,vendor:"vld",validate:e=>{const s=this.safeParse(e);return s.success?{value:s.data}:{issues:[{message:s.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: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 s=this.safeParse(e);return s.success?{success:!0,data:s.data}:s}async encodeAsync(e){return this.parseAsync(e)}async safeEncodeAsync(e){const s=await this.safeParseAsync(e);return s.success?{success:!0,data:s.data}:s}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,s){const r=this.safeParse(e);if(r.success)return r.data;const t=this.safeParse(s);if(!t.success)throw new Error(`Invalid default value provided: ${t.error.message}`);return t.data}refine(e,s){return new VldRefine(this,e,s)}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,r(e,"Expected non-optional value"))}array(){return a.array(this)}or(e){return a.union(this,e)}and(e){return a.intersection(this,e)}overwrite(e){return new VldTransform(this,e)}with(...e){return new VldSuperRefine(this,(s,r)=>{const a={value:s,issues:[]},n=[];for(const s of e){const e="function"==typeof s?s:s._zod?.check;if(!e)continue;const r=e(a);t(r)&&n.push(Promise.resolve(r))}const i=()=>{for(const e of a.issues)r.addIssue(void 0===e.code?{message:e.message||"Custom check failed"}:{message:e.message||"Custom check failed",code:e.code})};if(n.length>0)return Promise.all(n).then(i);i()})}toJSONSchema(e){return a.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,s){return new VldRefine(this,e,s)}meta(s){if(void 0===s)return e.get(this);const r=new VldMeta(this,s);return e.add(r,s),r}register(e,s){return e.add(this,s),this}describe(e){return this.meta({description:e})}get description(){return this.meta()?.description}}class VldMeta extends VldBase{constructor(e,r){super(s.META),this.baseValidator=e,this.metadata=r}parse(e){return this.baseValidator.parse(e)}safeParse(e){return this.baseValidator.safeParse(e)}getMeta(){return{...this.metadata}}meta(s){if(void 0===s)return{...this.metadata,...e.get(this)};const r=new VldMeta(this.baseValidator,{...this.metadata,...s});return e.add(r,r.getMeta()),r}describe(e){return this.meta({description:e})}}class VldReadonly extends VldBase{constructor(e){super(s.READONLY),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const s=this.baseValidator.safeParse(e);return s.success?{success:!0,data:s.data}:{success:!1,error:s.error}}}class VldBrand extends VldBase{constructor(e){super(s.BRAND),this.baseValidator=e}parse(e){return this.baseValidator.parse(e)}safeParse(e){const s=this.baseValidator.safeParse(e);return s.success?{success:!0,data:s.data}:{success:!1,error:s.error}}}class VldRefine extends VldBase{constructor(e,r,t){super(s.REFINE),this.baseValidator=e,this.predicate=r,this.customMessage=t}parse(e){const s=this.baseValidator.parse(e),r=this.predicate(s);if(t(r))throw new Error("Use parseAsync for async refinements");if(!r)throw new Error(this.customMessage||"Refinement check failed");return s}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:e}}}async parseAsync(e){const s=await this.baseValidator.parseAsync(e);if(!await this.predicate(s))throw new Error(this.customMessage||"Refinement check failed");return s}}class VldTransform extends VldBase{constructor(e,r){super(s.TRANSFORM),this.baseValidator=e,this.transformer=r}parse(e){const s=this.baseValidator.parse(e);try{const e=this.transformer(s);if(t(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:e}}}async parseAsync(e){const s=await this.baseValidator.parseAsync(e);try{return await this.transformer(s)}catch(e){throw new Error(`Transform failed: ${e.message}`)}}}class VldDefault extends VldBase{constructor(e,r){super(s.DEFAULT),this.baseValidator=e,this.defaultValue=r}parse(e){return void 0===e?i(this.defaultValue):this.baseValidator.parse(e)}safeParse(e){return void 0===e?{success:!0,data:i(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,r){super(s.PREFAULT),this.baseValidator=e,this.defaultValue=r}parse(e){return void 0===e?this.baseValidator.parse(i(this.defaultValue)):this.baseValidator.parse(e)}safeParse(e){return void 0===e?this.baseValidator.safeParse(i(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,r){super(s.CATCH),this.baseValidator=e,this.fallbackValue=r,this.simpleMode=o(e);const t=e.safeParse(r);if(!t.success)throw new Error(`Invalid fallback value: ${t.error.message}`)}parse(e){const s=c(this.simpleMode,e);if(void 0!==s)return s;if(void 0!==this.simpleMode)return this.fallbackValue;try{return this.baseValidator.parse(e)}catch{return this.fallbackValue}}safeParse(e){const s=c(this.simpleMode,e);if(void 0!==s)return{success:!0,data:s};if(void 0!==this.simpleMode)return{success:!0,data:this.fallbackValue};const r=this.baseValidator.safeParse(e);return r.success?r:{success:!0,data:this.fallbackValue}}}class VldOptional extends VldBase{constructor(e){super(s.OPTIONAL),this.baseValidator=e,this.simpleMode=o(e)}parseSimpleValue(e){return c(this.simpleMode,e)}static create(e){return new VldOptional(e)}parse(e){if(void 0===e)return;const s=this.parseSimpleValue(e);return void 0!==s?s:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const s=this.parseSimpleValue(e);return void 0!==s?{success:!0,data:s}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldExactOptional extends VldBase{constructor(e){super(s.EXACT_OPTIONAL),this.baseValidator=e,this.simpleMode=o(e)}static create(e){return new VldExactOptional(e)}parse(e){if(void 0===e)return;const s=c(this.simpleMode,e);return void 0!==s?s:this.baseValidator.parse(e)}safeParse(e){if(void 0===e)return{success:!0,data:void 0};const s=c(this.simpleMode,e);return void 0!==s?{success:!0,data:s}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullable extends VldBase{constructor(e){super(s.NULLABLE),this.baseValidator=e,this.simpleMode=o(e)}static create(e){return new VldNullable(e)}parse(e){if(null===e)return null;const s=c(this.simpleMode,e);return void 0!==s?s:this.baseValidator.parse(e)}safeParse(e){if(null===e)return{success:!0,data:null};const s=c(this.simpleMode,e);return void 0!==s?{success:!0,data:s}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldNullish extends VldBase{constructor(e){super(s.NULLISH),this.baseValidator=e,this.simpleMode=o(e)}static create(e){return new VldNullish(e)}parse(e){if(null==e)return e;const s=c(this.simpleMode,e);return void 0!==s?s:this.baseValidator.parse(e)}safeParse(e){if(null==e)return{success:!0,data:e};const s=c(this.simpleMode,e);return void 0!==s?{success:!0,data:s}:this.baseValidator.safeParse(e)}unwrap(){return this.baseValidator}}class VldPipe extends VldBase{constructor(e,r){super(s.PIPE),this.first=e,this.second=r}parse(e){const s=this.first.parse(e);return this.second.parse(s)}safeParse(e){const s=this.first.safeParse(e);return s.success?this.second.safeParse(s.data):{success:!1,error:s.error}}}class VldSuperRefine extends VldBase{constructor(e,r){super(s.SUPER_REFINE),this._inner=e,this._refinement=r}parse(e){const s=this._inner.parse(e),r=[],t={addIssue:e=>r.push(e),path:[]};if(this._refinement(s,t)instanceof Promise)throw new Error("Use parseAsync for async refinements");if(r.length>0)throw new Error(r.map(e=>e.message).join("; "));return s}safeParse(e){const s=this._inner.safeParse(e);if(!s.success)return{success:!1,error:s.error};const r=[],t={addIssue:e=>r.push(e),path:[]};if(this._refinement(s.data,t)instanceof Promise)throw new Error("Use safeParseAsync for async refinements");return r.length>0?{success:!1,error:new Error(r.map(e=>e.message).join("; "))}:s}async parseAsync(e){const s=await this._inner.parseAsync(e),r=[],t={addIssue:e=>r.push(e),path:[]};if(await this._refinement(s,t),r.length>0)throw new Error(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:e}}}}class VldPreprocess extends VldBase{constructor(e,r){super(s.PREPROCESS),this._preprocessor=e,this._schema=r}static create(e,s){return new VldPreprocess(e,s)}parse(e){const s=this._preprocessor(e);return this._schema.parse(s)}safeParse(e){try{const s=this._preprocessor(e);return this._schema.safeParse(s)}catch(e){return{success:!1,error:e}}}}export{s as VLD_VALIDATOR_TYPES,VldBase,VldBrand,VldCatch,VldDefault,VldExactOptional,VldMeta,VldNullable,VldNullish,VldOptional,VldPipe,VldPrefault,VldPreprocess,VldReadonly,VldRefine,VldSuperRefine,VldTransform,n as configureSchemaCompositionFactories,r as resolveErrorMessage};
1
+ import{globalRegistry as e}from"../registry.js";import{V as t}from"../chunks/errors-core-CerMg2rq.js";function s(e){if(e instanceof t)return e;const s=e instanceof Error?e.message:String(e);return new t([{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){n=e}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 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.get(this)??this.baseValidator?.meta?.()??this.schema?.meta?.()??this.inner?.meta?.();const s=new VldMeta(this,t);return e.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.get(this)};const s=new VldMeta(this.baseValidator,{...this.metadata,...t});return e.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([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([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?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(r.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(r.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=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=u(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=u(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=u(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=u(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(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(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(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)}}}}export{r as VLD_VALIDATOR_TYPES,VldBase,VldBrand,VldCatch,VldDefault,VldExactOptional,VldMeta,VldNullable,VldNullish,VldOptional,VldPipe,VldPrefault,VldPreprocess,VldReadonly,VldRefine,VldSuperRefine,VldTransform,o as configureSchemaCompositionFactories,s as ensureVldError,i as isPromiseLike,a as resolveErrorMessage};
@@ -1 +1 @@
1
- import{VldBase as e,VLD_VALIDATOR_TYPES as s}from"./base.js";import{createIssue as r}from"../errors.js";import{getMessages as t}from"../locales/runtime.js";import{V as a}from"../chunks/errors-core-Cqi4-9ew.js";class VldBase64 extends e{constructor(e=!1){super(s.BASE64),this.urlSafe=e}parse(e){const s=this.safeParse(e);if(!s.success)throw s.error;return s.data}safeParse(e){if("string"!=typeof e)return{success:!1,error:new a([r("invalid_type",[],t().expectedString)])};return(this.urlSafe?VldBase64.BASE64_URL_REGEX:VldBase64.BASE64_REGEX).test(e)?!this.urlSafe&&e.length>0&&e.length%4!=0?{success:!1,error:new a([r("custom",[],t().invalidBase64)])}:{success:!0,data:e}:{success:!1,error:new a([r("custom",[],t().invalidBase64)])}}urlSafeMode(){return new VldBase64(!0)}static create(e=!1){return new VldBase64(e)}}VldBase64.BASE64_REGEX=/^[A-Za-z0-9+/]*={0,2}$/,VldBase64.BASE64_URL_REGEX=/^[A-Za-z0-9_-]*={0,2}$/;export{VldBase64};
1
+ import{VldBase as e,VLD_VALIDATOR_TYPES as s}from"./base.js";import{createIssue as r}from"../errors.js";import{getMessages as t}from"../locales/runtime.js";import{V as a}from"../chunks/errors-core-CerMg2rq.js";class VldBase64 extends e{constructor(e=!1){super(s.BASE64),this.urlSafe=e}parse(e){const s=this.safeParse(e);if(!s.success)throw s.error;return s.data}safeParse(e){if("string"!=typeof e)return{success:!1,error:new a([r("invalid_type",[],t().expectedString)])};return(this.urlSafe?VldBase64.BASE64_URL_REGEX:VldBase64.BASE64_REGEX).test(e)?!this.urlSafe&&e.length>0&&e.length%4!=0?{success:!1,error:new a([r("custom",[],t().invalidBase64)])}:{success:!0,data:e}:{success:!1,error:new a([r("custom",[],t().invalidBase64)])}}urlSafeMode(){return new VldBase64(!0)}static create(e=!1){return new VldBase64(e)}}VldBase64.BASE64_REGEX=/^[A-Za-z0-9+/]*={0,2}$/,VldBase64.BASE64_URL_REGEX=/^[A-Za-z0-9_-]*={0,2}$/;export{VldBase64};
@@ -31,6 +31,9 @@ export declare class VldBigInt extends VldBase<bigint, bigint> {
31
31
  protected constructor(config?: Partial<BigIntValidatorConfig>);
32
32
  get jsonSchema(): BigIntJSONSchemaHints | undefined;
33
33
  get isSimple(): boolean;
34
+ get minValue(): bigint | null;
35
+ get maxValue(): bigint | null;
36
+ get format(): string | null;
34
37
  /**
35
38
  * Create a new bigint validator
36
39
  */
@@ -94,5 +97,9 @@ export declare class VldBigInt extends VldBase<bigint, bigint> {
94
97
  * Zod 4 API parity - alias for max()
95
98
  */
96
99
  lte(value: bigint | number, message?: string): VldBigInt;
100
+ /**
101
+ * Create a new validator with multiple of constraint
102
+ */
103
+ multipleOf(divisor: bigint, message?: string): VldBigInt;
97
104
  }
98
105
  export {};
@@ -1 +1 @@
1
- import{VldBase as e,VLD_VALIDATOR_TYPES as i}from"./base.js";import{getMessages as n}from"../locales/runtime.js";import{V as t}from"../chunks/errors-core-Cqi4-9ew.js";function s(e){return new t([{code:"invalid_type",path:[],message:e}])}class VldBigInt extends e{constructor(e){super(e?.validatorType||i.BIGINT),this.config={checks:e?.checks||[],errorMessage:e?.errorMessage,jsonSchema:e?.jsonSchema},this._checks=this.config.checks,this._fastCheckMode=this.detectFastCheckMode()}get jsonSchema(){return this.config.jsonSchema}get isSimple(){return 0===this._checks.length}static create(){return new VldBigInt}detectFastCheckMode(){if(0===this._checks.length)return"none";if(1!==this._checks.length)return;const e=this.config.jsonSchema;return 0n===e?.exclusiveMinimum&&void 0===e.minimum&&void 0===e.maximum?"positive":0n===e?.exclusiveMaximum&&void 0===e.minimum&&void 0===e.maximum?"negative":0n===e?.minimum&&void 0===e.maximum&&void 0===e.exclusiveMaximum?"nonnegative":0n===e?.maximum&&void 0===e.minimum&&void 0===e.exclusiveMinimum?"nonpositive":void 0}getValidationError(){return new Error(this.config.errorMessage||n().invalidBigint)}parse(e){if("bigint"!=typeof e)throw this.getValidationError();return this.parseKnownBigInt(e)}parseKnownBigInt(e){switch(this._fastCheckMode){case"none":return e;case"positive":if(e>0n)return e;throw this.getValidationError();case"negative":if(e<0n)return e;throw this.getValidationError();case"nonnegative":if(e>=0n)return e;throw this.getValidationError();case"nonpositive":if(e<=0n)return e;throw this.getValidationError()}for(const i of this._checks)if(!i(e))throw this.getValidationError();return e}safeParse(e){if("bigint"!=typeof e)return{success:!1,error:s(this.getValidationError().message)};try{return{success:!0,data:this.parseKnownBigInt(e)}}catch(e){return{success:!1,error:s(e.message)}}}min(e,i){return new VldBigInt({...this.config,checks:[...this.config.checks,i=>i>=e],errorMessage:i||`BigInt must be at least ${e}`,jsonSchema:{...this.config.jsonSchema,minimum:e}})}max(e,i){return new VldBigInt({...this.config,checks:[...this.config.checks,i=>i<=e],errorMessage:i||`BigInt must be at most ${e}`,jsonSchema:{...this.config.jsonSchema,maximum:e}})}positive(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>0n],errorMessage:e||"BigInt must be positive",jsonSchema:{...this.config.jsonSchema,exclusiveMinimum:0n}})}negative(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<0n],errorMessage:e||"BigInt must be negative",jsonSchema:{...this.config.jsonSchema,exclusiveMaximum:0n}})}nonnegative(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>=0n],errorMessage:e||"BigInt must be non-negative",jsonSchema:{...this.config.jsonSchema,minimum:0n}})}nonpositive(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<=0n],errorMessage:e||"BigInt must be non-positive",jsonSchema:{...this.config.jsonSchema,maximum:0n}})}gt(e,i){const n="bigint"==typeof e?e:BigInt(e);return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>n],errorMessage:i||`BigInt must be greater than ${n}`,jsonSchema:{...this.config.jsonSchema,exclusiveMinimum:n}})}lt(e,i){const n="bigint"==typeof e?e:BigInt(e);return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<n],errorMessage:i||`BigInt must be less than ${n}`,jsonSchema:{...this.config.jsonSchema,exclusiveMaximum:n}})}gte(e,i){const n="bigint"==typeof e?e:BigInt(e);return this.min(n,i)}lte(e,i){const n="bigint"==typeof e?e:BigInt(e);return this.max(n,i)}}export{VldBigInt};
1
+ import{VldBase as e,VLD_VALIDATOR_TYPES as i}from"./base.js";import{getMessages as n}from"../locales/runtime.js";import{V as t}from"../chunks/errors-core-CerMg2rq.js";function s(e){return new t([{code:"invalid_type",path:[],message:e}])}class VldBigInt extends e{constructor(e){super(e?.validatorType||i.BIGINT),this.config={checks:e?.checks||[],errorMessage:e?.errorMessage,jsonSchema:e?.jsonSchema},this._checks=this.config.checks,this._fastCheckMode=this.detectFastCheckMode()}get jsonSchema(){return this.config.jsonSchema}get isSimple(){return 0===this._checks.length}get minValue(){return this.config.jsonSchema?.minimum?BigInt(this.config.jsonSchema.minimum):null}get maxValue(){return this.config.jsonSchema?.maximum?BigInt(this.config.jsonSchema.maximum):null}get format(){return this.config.jsonSchema?.format??null}static create(){return new VldBigInt}detectFastCheckMode(){if(0===this._checks.length)return"none";if(1!==this._checks.length)return;const e=this.config.jsonSchema;return 0n===e?.exclusiveMinimum&&void 0===e.minimum&&void 0===e.maximum?"positive":0n===e?.exclusiveMaximum&&void 0===e.minimum&&void 0===e.maximum?"negative":0n===e?.minimum&&void 0===e.maximum&&void 0===e.exclusiveMaximum?"nonnegative":0n===e?.maximum&&void 0===e.minimum&&void 0===e.exclusiveMinimum?"nonpositive":void 0}getValidationError(){return new Error(this.config.errorMessage||n().invalidBigint)}parse(e){if("bigint"!=typeof e)throw this.getValidationError();return this.parseKnownBigInt(e)}parseKnownBigInt(e){switch(this._fastCheckMode){case"none":return e;case"positive":if(e>0n)return e;throw this.getValidationError();case"negative":if(e<0n)return e;throw this.getValidationError();case"nonnegative":if(e>=0n)return e;throw this.getValidationError();case"nonpositive":if(e<=0n)return e;throw this.getValidationError()}for(const i of this._checks)if(!i(e))throw this.getValidationError();return e}safeParse(e){if("bigint"!=typeof e)return{success:!1,error:s(this.getValidationError().message)};try{return{success:!0,data:this.parseKnownBigInt(e)}}catch(e){return{success:!1,error:s(e.message)}}}min(e,i){return new VldBigInt({...this.config,checks:[...this.config.checks,i=>i>=e],errorMessage:i||`BigInt must be at least ${e}`,jsonSchema:{...this.config.jsonSchema,minimum:e}})}max(e,i){return new VldBigInt({...this.config,checks:[...this.config.checks,i=>i<=e],errorMessage:i||`BigInt must be at most ${e}`,jsonSchema:{...this.config.jsonSchema,maximum:e}})}positive(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>0n],errorMessage:e||"BigInt must be positive",jsonSchema:{...this.config.jsonSchema,exclusiveMinimum:0n}})}negative(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<0n],errorMessage:e||"BigInt must be negative",jsonSchema:{...this.config.jsonSchema,exclusiveMaximum:0n}})}nonnegative(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>=0n],errorMessage:e||"BigInt must be non-negative",jsonSchema:{...this.config.jsonSchema,minimum:0n}})}nonpositive(e){return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<=0n],errorMessage:e||"BigInt must be non-positive",jsonSchema:{...this.config.jsonSchema,maximum:0n}})}gt(e,i){const n="bigint"==typeof e?e:BigInt(e);return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e>n],errorMessage:i||`BigInt must be greater than ${n}`,jsonSchema:{...this.config.jsonSchema,exclusiveMinimum:n}})}lt(e,i){const n="bigint"==typeof e?e:BigInt(e);return new VldBigInt({...this.config,checks:[...this.config.checks,e=>e<n],errorMessage:i||`BigInt must be less than ${n}`,jsonSchema:{...this.config.jsonSchema,exclusiveMaximum:n}})}gte(e,i){const n="bigint"==typeof e?e:BigInt(e);return this.min(n,i)}lte(e,i){const n="bigint"==typeof e?e:BigInt(e);return this.max(n,i)}multipleOf(e,i){return new VldBigInt({...this.config,checks:[...this.config.checks,i=>i%e===0n],errorMessage:i||`BigInt must be a multiple of ${e}`,jsonSchema:{...this.config.jsonSchema,multipleOf:e}})}}export{VldBigInt};
@@ -1 +1 @@
1
- import{VldBase as e,VLD_VALIDATOR_TYPES as s}from"./base.js";import{V as r,c as t,g as a}from"../chunks/errors-core-Cqi4-9ew.js";class VldBoolean extends e{constructor(e,r){super(r||s.BOOLEAN),this.errorMessage=e}get isSimple(){return!0}static create(){return new VldBoolean}parse(e){if("boolean"!=typeof e)throw new r([t("boolean",a(e),this.errorMessage)]);return e}parseKnownBoolean(e){return e}safeParse(e){return"boolean"==typeof e?{success:!0,data:e}:{success:!1,error:new r([t("boolean",a(e),this.errorMessage)])}}true(e){return new VldTrue(e||"Value must be true")}false(e){return new VldFalse(e||"Value must be false")}}class VldTrue extends VldBoolean{constructor(e){super(e),this.message=e}get isSimple(){return!1}parse(e){if(!0!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!0}parseKnownBoolean(e){if(!0!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!0}safeParse(e){return!0!==e?{success:!1,error:new r([{code:"custom",path:[],message:this.message}])}:{success:!0,data:!0}}}class VldFalse extends VldBoolean{constructor(e){super(e),this.message=e}get isSimple(){return!1}parse(e){if(!1!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!1}parseKnownBoolean(e){if(!1!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!1}safeParse(e){return!1!==e?{success:!1,error:new r([{code:"custom",path:[],message:this.message}])}:{success:!0,data:!1}}}export{VldBoolean};
1
+ import{VldBase as e,VLD_VALIDATOR_TYPES as s}from"./base.js";import{V as r,c as t,g as a}from"../chunks/errors-core-CerMg2rq.js";class VldBoolean extends e{constructor(e,r){super(r||s.BOOLEAN),this.errorMessage=e}get isSimple(){return!0}static create(){return new VldBoolean}parse(e){if("boolean"!=typeof e)throw new r([t("boolean",a(e),this.errorMessage)]);return e}parseKnownBoolean(e){return e}safeParse(e){return"boolean"==typeof e?{success:!0,data:e}:{success:!1,error:new r([t("boolean",a(e),this.errorMessage)])}}true(e){return new VldTrue(e||"Value must be true")}false(e){return new VldFalse(e||"Value must be false")}}class VldTrue extends VldBoolean{constructor(e){super(e),this.message=e}get isSimple(){return!1}parse(e){if(!0!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!0}parseKnownBoolean(e){if(!0!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!0}safeParse(e){return!0!==e?{success:!1,error:new r([{code:"custom",path:[],message:this.message}])}:{success:!0,data:!0}}}class VldFalse extends VldBoolean{constructor(e){super(e),this.message=e}get isSimple(){return!1}parse(e){if(!1!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!1}parseKnownBoolean(e){if(!1!==e)throw new r([{code:"custom",path:[],message:this.message}]);return!1}safeParse(e){return!1!==e?{success:!1,error:new r([{code:"custom",path:[],message:this.message}])}:{success:!0,data:!1}}}export{VldBoolean};
@@ -1 +1 @@
1
- import{VldBase as r,VLD_VALIDATOR_TYPES as s}from"./base.js";import{createIssue as e}from"../errors.js";import{getMessages as t}from"../locales/runtime.js";import{V as c}from"../chunks/errors-core-Cqi4-9ew.js";class VldCodec extends r{constructor(r,e,t){super(s.CODEC),this.inputValidator=r,this.outputValidator=e,this.codecTransform=t}parse(r){const s=this.safeParse(r);if(!s.success)throw s.error;return s.data}safeParse(r){const s=this.inputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=this.codecTransform.decode(s.data);if(r instanceof Promise)throw new c([e("custom",[],t().codecAsyncNotSupported)]);return this.outputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecDecodeFailed)])}}}invert(){return new VldCodec(this.outputValidator,this.inputValidator,{decode:this.codecTransform.encode,encode:this.codecTransform.decode})}encode(r){const s=this.safeEncode(r);if(!s.success)throw s.error;return s.data}safeEncode(r){const s=this.outputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=this.codecTransform.encode(s.data);if(r instanceof Promise)throw new c([e("custom",[],t().codecAsyncNotSupported)]);return this.inputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecEncodeFailed)])}}}async parseAsync(r){const s=await this.safeParseAsync(r);if(!s.success)throw s.error;return s.data}async safeParseAsync(r){const s=this.inputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=await this.codecTransform.decode(s.data);return this.outputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecDecodeFailed)])}}}async encodeAsync(r){const s=await this.safeEncodeAsync(r);if(!s.success)throw s.error;return s.data}async safeEncodeAsync(r){const s=this.outputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=await this.codecTransform.encode(s.data);return this.inputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecEncodeFailed)])}}}static create(r,s,e){return new VldCodec(r,s,e)}static invert(r){return r.invert()}}export{VldCodec};
1
+ import{VldBase as r,VLD_VALIDATOR_TYPES as s}from"./base.js";import{createIssue as e}from"../errors.js";import{getMessages as t}from"../locales/runtime.js";import{V as c}from"../chunks/errors-core-CerMg2rq.js";class VldCodec extends r{constructor(r,e,t){super(s.CODEC),this.inputValidator=r,this.outputValidator=e,this.codecTransform=t}parse(r){const s=this.safeParse(r);if(!s.success)throw s.error;return s.data}safeParse(r){const s=this.inputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=this.codecTransform.decode(s.data);if(r instanceof Promise)throw new c([e("custom",[],t().codecAsyncNotSupported)]);return this.outputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecDecodeFailed)])}}}invert(){return new VldCodec(this.outputValidator,this.inputValidator,{decode:this.codecTransform.encode,encode:this.codecTransform.decode})}encode(r){const s=this.safeEncode(r);if(!s.success)throw s.error;return s.data}safeEncode(r){const s=this.outputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=this.codecTransform.encode(s.data);if(r instanceof Promise)throw new c([e("custom",[],t().codecAsyncNotSupported)]);return this.inputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecEncodeFailed)])}}}async parseAsync(r){const s=await this.safeParseAsync(r);if(!s.success)throw s.error;return s.data}async safeParseAsync(r){const s=this.inputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=await this.codecTransform.decode(s.data);return this.outputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecDecodeFailed)])}}}async encodeAsync(r){const s=await this.safeEncodeAsync(r);if(!s.success)throw s.error;return s.data}async safeEncodeAsync(r){const s=this.outputValidator.safeParse(r);if(!s.success)return{success:!1,error:s.error};try{const r=await this.codecTransform.encode(s.data);return this.inputValidator.safeParse(r)}catch(r){return r instanceof c?{success:!1,error:r}:{success:!1,error:new c([e("custom",[],t().codecEncodeFailed)])}}}static create(r,s,e){return new VldCodec(r,s,e)}static invert(r){return r.invert()}}export{VldCodec};
@@ -1,4 +1,4 @@
1
- import { VldBase, ParseResult } from './base.js';
1
+ import { VldBase, ParseResult, type ErrorParam } from './base.js';
2
2
  /**
3
3
  * Type-safe custom validator options
4
4
  */
@@ -16,12 +16,24 @@ export interface CustomValidatorOptions<TOutput> {
16
16
  * Optional safeParse implementation
17
17
  * If not provided, will use try-catch around parse()
18
18
  */
19
- safeParse?: (value: unknown) => ParseResult<TOutput>;
19
+ safeParse?: (value: unknown) => ParseResult<TOutput> | {
20
+ success: true;
21
+ data: TOutput;
22
+ } | {
23
+ success: false;
24
+ error: Error;
25
+ };
20
26
  /**
21
27
  * Optional async safeParse implementation
22
28
  * If not provided, will use try-catch around parseAsync()
23
29
  */
24
- safeParseAsync?: (value: unknown) => Promise<ParseResult<TOutput>>;
30
+ safeParseAsync?: (value: unknown) => Promise<ParseResult<TOutput> | {
31
+ success: true;
32
+ data: TOutput;
33
+ } | {
34
+ success: false;
35
+ error: Error;
36
+ }>;
25
37
  }
26
38
  /**
27
39
  * Immutable custom validator for user-defined validation logic
@@ -50,11 +62,9 @@ export declare class VldCustom<TOutput = unknown> extends VldBase<unknown, TOutp
50
62
  }
51
63
  /**
52
64
  * Helper function to create custom validators
53
- * Usage: v.custom<number>({
54
- * parse: (value) => {
55
- * if (typeof value !== 'string') throw new Error('Expected string');
56
- * return parseInt(value, 10);
57
- * }
58
- * })
65
+ * Supports:
66
+ * - v.custom() -> accepts any
67
+ * - v.custom((val) => boolean, "error message")
68
+ * - v.custom({ parse: (val) => ... })
59
69
  */
60
- export declare function custom<TOutput = unknown>(options: CustomValidatorOptions<TOutput>): VldCustom<TOutput>;
70
+ export declare function custom<TOutput = unknown>(optionsOrPredicate?: CustomValidatorOptions<TOutput> | ((data: unknown) => boolean | Promise<boolean>), errorParam?: ErrorParam): VldCustom<TOutput>;