Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@esmj/schema

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esmj/schema - npm Package Compare versions

Comparing version
0.6.0
to
0.7.0
+1
dist/chunk-ELVLLQRH.mjs
import {c}from'./chunk-V2T3CZFC.mjs';c((a,o,m)=>{if(m?.type==="array"){let r=a;r.min=function(e,{message:t}={}){return this.refine(n=>n.length>=e,{message:t||`Array must contain at least ${e} items.`})},r.max=function(e,{message:t}={}){return this.refine(n=>n.length<=e,{message:t||`Array must contain at most ${e} items.`})},r.length=function(e,{message:t}={}){return this.refine(n=>n.length===e,{message:t||`Array must contain exactly ${e} items.`})},r.nonEmpty=function({message:e}={}){return this.refine(t=>t.length>0,{message:e||"Array must not be empty."})},r.unique=function({message:e}={}){return this.refine(t=>{let n=new Set;try{return t.every(c=>{let s=JSON.stringify(c);return n.has(s)?!1:(n.add(s),!0)})}catch{return new Set(t).size===t.length}},{message:e||"Array items must be unique."})},r.sort=function(){return this.transform(e=>[...e].sort())},r.reverse=function(){return this.transform(e=>[...e].reverse())};}return a});
import {c}from'./chunk-V2T3CZFC.mjs';c((i,s,c)=>{if(c?.type==="string"){let r=i;r.min=function(t,{message:n}={}){return this.refine(e=>e.length>=t,{message:n||(e=>`String must be at least ${t} characters long (received ${e.length} characters: "${e}")`)})},r.max=function(t,{message:n}={}){return this.refine(e=>e.length<=t,{message:n||(e=>`String must be at most ${t} characters long (received ${e.length} characters: "${e}")`)})},r.length=function(t,{message:n}={}){return this.refine(e=>e.length===t,{message:n||(e=>`String must be exactly ${t} characters long (received ${e.length} characters: "${e}")`)})},r.nonEmpty=function({message:t}={}){return this.refine(n=>n.length>0,{message:t||"String must not be empty (received empty string)"})},r.startsWith=function(t,{message:n}={}){return this.refine(e=>e.startsWith(t),{message:n||(e=>`String must start with "${t}" (received: "${e}")`)})},r.endsWith=function(t,{message:n}={}){return this.refine(e=>e.endsWith(t),{message:n||(e=>`String must end with "${t}" (received: "${e}")`)})},r.includes=function(t,{message:n}={}){return this.refine(e=>e.includes(t),{message:n||(e=>`String must include "${t}" (received: "${e}")`)})},r.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},r.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},r.trim=function(){return this.transform(t=>t.trim())},r.padStart=function(t,n=" "){return this.transform(e=>e.padStart(t,n))},r.padEnd=function(t,n=" "){return this.transform(e=>e.padEnd(t,n))},r.replace=function(t,n){return this.transform(e=>e.replace(t,n))};}return i});
var k={abortEarly:true};function d(e,s){if(!s)return e;let i=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function T(e,s,i){if(e.errors?.length)for(let u=0;u<e.errors.length;u++)s.push(d(e.errors[u],i));}function y(e){return {...k,...e}}var x=e=>typeof e=="string"||e instanceof String,w=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),P=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),b=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$={object(e,s){let i=l(b,{...s,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([p,c])=>`${p}: ${c._getDescription()}`).join(", ")} })`,h(i,"_parse",(u,p,c)=>{let t=u(p,c),{abortEarly:n}=y(c);if(t.success===false)return t;let a={},r=[];for(let o in e){let f=e[o]._parse(t.data[o],c);if(f.success)a[o]=f.data;else {if(f=f,n!==false){let m=d(f.error,o);return {success:false,error:m,errors:[m]}}T(f,r,o);}}return r.length>0?{success:false,error:r[0],errors:r}:{success:true,data:a}}),i},string(e){return l(x,{...e,type:"string"})},number(e){return l(w,{...e,type:"number"})},boolean(e){return l(P,{...e,type:"boolean"})},date(e){return l(E,{...e,type:"date"})},enum(e,s){let i=t=>e.includes(t),u=t=>`Invalid ${p} value. Expected ${e.map(n=>`"${n}"`).join(" | ")}, received "${t}".`,p="enum",c=l(i,{message:u,...s,type:p});return c._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,c},array(e,s){let i=l(_,{...s,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,h(i,"_parse",(u,p,c)=>{let t=u(p,c),{abortEarly:n}=y(c);if(t.success===false)return t;let a=[],r=[];for(let o=0;o<t.data.length;o++){let f=e._parse(t.data[o],c);if(f.success)a.push(f.data);else {if(f=f,n!==false){let m=d(f.error,o);return {success:false,error:m,errors:[m]}}T(f,r,o);}}return r.length>0?{success:false,error:r[0],errors:r}:{success:true,data:a}}),i},any(){return l(()=>true)},preprocess(e,s){return h(s,"_parse",(i,u)=>(u=e(u),i(u))),s},union(e,s){return l(c=>{for(let t=0;t<e.length;t++){let n=e[t]._parse(c);if(n.success)return n}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,n)=>` ${n+1}. ${t._getDescription()}`).join(",")} but received "${typeof c}" with value: ${b(c)?JSON.stringify(c):`"${c}"`}`,...s,type:"union"})},literal(e,s){let p=l(c=>c===e,{message:c=>s?.message?typeof s.message=="function"?s.message(c):s.message:`Expected literal value "${e}", received "${c}"`,name:s?.name,type:"literal"});return p._getDescription=()=>`literal("${e}")`,p}};function O(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function h(e,s,i){let u=e[s];e[s]=(...p)=>i(u,...p);}function l(e,{type:s="any",name:i,message:u}={}){u=u||O(s);let p={name:i,message:u,type:s},c={_getName(){return i},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(t,n){let a=e(t);if(a===true)return {success:true,data:t};if(typeof a=="object"&&a?.success===true)return a;let r={message:typeof u=="function"?u(t):u};return {success:false,error:r,errors:[r]}},parse(t,n){let a=c._parse(t,n);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(t,n){return c._parse(t,n)},transform(t){return h(this,"_parse",(n,a,r)=>{let o=n(a,r);return o.success&&(o.data=t(o.data)),o}),this},optional(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n===void 0&&(r.data=void 0,r.success=true),r}),this},nullable(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n===null&&(r.data=null,r.success=true),r}),this},nullish(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n==null&&(r.success=true,r.data=n),r}),this},default(t){return h(this,"_parse",(n,a,r)=>(a===void 0&&(a=typeof t=="function"?t():t),n(a,r))),this},pipe(t){return h(this,"_parse",(n,a,r)=>{let o=n(a,r);return o.success?t._parse(o.data,r):o}),this},refine(t,{message:n,type:a}={}){return a&&(n=n||O(a),s=a),h(this,"_parse",(r,o,f)=>{let m=r(o,f);y(f);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let g={message:typeof n=="function"?n(o):n};return {success:false,error:g,errors:[g]}}),this}};return S.length>0?S.reduce((t,n)=>n(t,e,p)??t,c):c}var S=[];function A(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");S.push(e);}export{$ as a,h as b,A as c};
import {c}from'./chunk-V2T3CZFC.mjs';c((i,c,m)=>{if(m?.type==="number"){let n=i;n.min=function(e,{message:t}={}){return this.refine(r=>r>=e,{message:t||`Number must be greater than or equal to ${e}.`})},n.max=function(e,{message:t}={}){return this.refine(r=>r<=e,{message:t||`Number must be less than or equal to ${e}.`})},n.positive=function({message:e}={}){return this.refine(t=>t>0,{message:e||"Number must be positive."})},n.negative=function({message:e}={}){return this.refine(t=>t<0,{message:e||"Number must be negative."})},n.int=function({message:e}={}){return this.refine(t=>Number.isInteger(t),{message:e||"Number must be an integer."})},n.float=function({message:e}={}){return this.refine(t=>Number.isFinite(t)&&!Number.isInteger(t),{message:e||"Number must be a floating point (non-integer)."})},n.multipleOf=function(e,{message:t}={}){return this.refine(r=>r%e===0,{message:t||`Number must be a multiple of ${e}.`})},n.finite=function({message:e}={}){return this.refine(t=>Number.isFinite(t),{message:e||"Number must be finite."})};}return i});
+1
-1

@@ -1,1 +0,1 @@

'use strict';var P={abortEarly:true};function l(e,o){if(!o)return e;let i=e?.cause?.key?`${o}.${e.cause.key}`:`${o}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function g(e,o,i){!e.errors||e.errors.length===0||e.errors.forEach(u=>{let c=l(u,i);o.push(c);});}function S(e){return {...P,...e}}var k=e=>typeof e=="string"||e instanceof String,A=e=>typeof e=="number"||e instanceof Number,w=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),O=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R={object(e,o){let i=y(O,{...o,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([c,s])=>`${c}: ${s._getDescription()}`).join(", ")} })`,h(i,"_parse",(u,c,s)=>{let t=u(c,s),{abortEarly:r}=S(s);if(t.success===false)return t;let n={},a=[];for(let p in e){let f=e[p]._parse(t.data[p],s);if(f.success)n[p]=f.data;else {if(f=f,r!==false){let m=l(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:n}}),i},string(e){return y(k,{...e,type:"string"})},number(e){return y(A,{...e,type:"number"})},boolean(e){return y(w,{...e,type:"boolean"})},date(e){return y(E,{...e,type:"date"})},enum(e,o){let i=t=>e.includes(t),u=t=>`Invalid ${c} value. Expected ${e.map(r=>`"${r}"`).join(" | ")}, received "${t}".`,c="enum",s=y(i,{message:u,...o,type:c});return s._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,s},array(e,o){let i=y(_,{...o,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,h(i,"_parse",(u,c,s)=>{let t=u(c,s),{abortEarly:r}=S(s);if(t.success===false)return t;let n=[],a=[];for(let p=0;p<t.data.length;p++){let f=e._parse(t.data[p],s);if(f.success)n.push(f.data);else {if(f=f,r!==false){let m=l(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:n}}),i},any(){return y(()=>true)},preprocess(e,o){return h(o,"_parse",(i,u)=>(u=e(u),i(u))),o},union(e,o){return y(s=>{for(let t=0;t<e.length;t++){let r=e[t]._parse(s);if(r.success)return r}return false},{message:s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,r)=>` ${r+1}. ${t._getDescription()}`).join(",")} but received "${typeof s}" with value: ${O(s)?JSON.stringify(s):`"${s}"`}`,...o,type:"union"})}};function b(e){return o=>`The value "${o}" must be type of ${e} but is type of "${typeof o}".`}function h(e,o,i){let u=e[o];e[o]=(...c)=>i(u,...c);}function y(e,{type:o="any",name:i,message:u}={}){u=u||b(o);let c={name:i,message:u,type:o},s={_getName(){return i},_getType(){return o},_getDescription(){return this._getName()??this._getType()},_parse(t,r){let n=e(t);if(n===true)return {success:true,data:t};if(typeof n=="object"&&n?.success===true)return n;let a={message:typeof u=="function"?u(t):u};return {success:false,error:a,errors:[a]}},parse(t,r){let n=s._parse(t,r);if(!n.success)throw n=n,new Error(n.error.message,{cause:n.error.cause});return n.data},safeParse(t,r){return s._parse(t,r)},transform(t){return h(this,"_parse",(r,n,a)=>{let p=r(n,a);return p.success&&(p.data=t(p.data)),p}),this},optional(){return h(this,"_parse",(t,r,n)=>{let a=t(r,n);return !a.success&&r===void 0&&(a.data=void 0,a.success=true),a}),this},nullable(){return h(this,"_parse",(t,r,n)=>{let a=t(r,n);return !a.success&&r===null&&(a.data=null,a.success=true),a}),this},nullish(){return h(this,"_parse",(t,r,n)=>{let a=t(r,n);return !a.success&&r==null&&(a.success=true,a.data=r),a}),this},default(t){return h(this,"_parse",(r,n,a)=>(n===void 0&&(n=t,n=typeof t=="function"?t():t),r(n,a))),this},pipe(t){return h(this,"_parse",(r,n,a)=>{let p=r(n,a);return p.success?t._parse(p.data,a):p}),this},refine(t,{message:r,type:n}={}){return n&&(r=r||b(n),o=n),h(this,"_parse",(a,p,f)=>{let m=a(p,f);S(f);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let T={message:typeof r=="function"?r(p):r};return {success:false,error:T,errors:[T]}}),this}};return d.length>0?d.reduce((t,r)=>r(t,e,c)??t,s):s}var d=[];function x(e){d.push(e);}x((e,o,i)=>{if(i?.type==="array"){let u=e;u.min=function(c,{message:s}={}){return this.refine(t=>t.length>=c,{message:s||`Array must contain at least ${c} items.`})},u.max=function(c,{message:s}={}){return this.refine(t=>t.length<=c,{message:s||`Array must contain at most ${c} items.`})},u.length=function(c,{message:s}={}){return this.refine(t=>t.length===c,{message:s||`Array must contain exactly ${c} items.`})},u.nonEmpty=function({message:c}={}){return this.refine(s=>s.length>0,{message:c||"Array must not be empty."})},u.unique=function({message:c}={}){return this.refine(s=>{let t=new Set;try{return s.every(r=>{let n=JSON.stringify(r);return t.has(n)?!1:(t.add(n),!0)})}catch{return new Set(s).size===s.length}},{message:c||"Array items must be unique."})},u.sort=function(){return this.transform(c=>[...c].sort())},u.reverse=function(){return this.transform(c=>[...c].reverse())};}return e});exports.extend=x;exports.hookOriginal=h;exports.s=R;
'use strict';var k={abortEarly:true};function y(e,c){if(!c)return e;let i=e?.cause?.key?`${c}.${e.cause.key}`:`${c}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function T(e,c,i){if(e.errors?.length)for(let u=0;u<e.errors.length;u++)c.push(y(e.errors[u],i));}function S(e){return {...k,...e}}var w=e=>typeof e=="string"||e instanceof String,P=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),A=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),b=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R={object(e,c){let i=h(b,{...c,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([o,r])=>`${o}: ${r._getDescription()}`).join(", ")} })`,l(i,"_parse",(u,o,r)=>{let t=u(o,r),{abortEarly:n}=S(r);if(t.success===false)return t;let a={},s=[];for(let p in e){let f=e[p]._parse(t.data[p],r);if(f.success)a[p]=f.data;else {if(f=f,n!==false){let m=y(f.error,p);return {success:false,error:m,errors:[m]}}T(f,s,p);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:a}}),i},string(e){return h(w,{...e,type:"string"})},number(e){return h(P,{...e,type:"number"})},boolean(e){return h(A,{...e,type:"boolean"})},date(e){return h(E,{...e,type:"date"})},enum(e,c){let i=t=>e.includes(t),u=t=>`Invalid ${o} value. Expected ${e.map(n=>`"${n}"`).join(" | ")}, received "${t}".`,o="enum",r=h(i,{message:u,...c,type:o});return r._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,r},array(e,c){let i=h(_,{...c,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,l(i,"_parse",(u,o,r)=>{let t=u(o,r),{abortEarly:n}=S(r);if(t.success===false)return t;let a=[],s=[];for(let p=0;p<t.data.length;p++){let f=e._parse(t.data[p],r);if(f.success)a.push(f.data);else {if(f=f,n!==false){let m=y(f.error,p);return {success:false,error:m,errors:[m]}}T(f,s,p);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:a}}),i},any(){return h(()=>true)},preprocess(e,c){return l(c,"_parse",(i,u)=>(u=e(u),i(u))),c},union(e,c){return h(r=>{for(let t=0;t<e.length;t++){let n=e[t]._parse(r);if(n.success)return n}return false},{message:r=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,n)=>` ${n+1}. ${t._getDescription()}`).join(",")} but received "${typeof r}" with value: ${b(r)?JSON.stringify(r):`"${r}"`}`,...c,type:"union"})},literal(e,c){let o=h(r=>r===e,{message:r=>c?.message?typeof c.message=="function"?c.message(r):c.message:`Expected literal value "${e}", received "${r}"`,name:c?.name,type:"literal"});return o._getDescription=()=>`literal("${e}")`,o}};function O(e){return c=>`The value "${c}" must be type of ${e} but is type of "${typeof c}".`}function l(e,c,i){let u=e[c];e[c]=(...o)=>i(u,...o);}function h(e,{type:c="any",name:i,message:u}={}){u=u||O(c);let o={name:i,message:u,type:c},r={_getName(){return i},_getType(){return c},_getDescription(){return this._getName()??this._getType()},_parse(t,n){let a=e(t);if(a===true)return {success:true,data:t};if(typeof a=="object"&&a?.success===true)return a;let s={message:typeof u=="function"?u(t):u};return {success:false,error:s,errors:[s]}},parse(t,n){let a=r._parse(t,n);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(t,n){return r._parse(t,n)},transform(t){return l(this,"_parse",(n,a,s)=>{let p=n(a,s);return p.success&&(p.data=t(p.data)),p}),this},optional(){return l(this,"_parse",(t,n,a)=>{let s=t(n,a);return !s.success&&n===void 0&&(s.data=void 0,s.success=true),s}),this},nullable(){return l(this,"_parse",(t,n,a)=>{let s=t(n,a);return !s.success&&n===null&&(s.data=null,s.success=true),s}),this},nullish(){return l(this,"_parse",(t,n,a)=>{let s=t(n,a);return !s.success&&n==null&&(s.success=true,s.data=n),s}),this},default(t){return l(this,"_parse",(n,a,s)=>(a===void 0&&(a=typeof t=="function"?t():t),n(a,s))),this},pipe(t){return l(this,"_parse",(n,a,s)=>{let p=n(a,s);return p.success?t._parse(p.data,s):p}),this},refine(t,{message:n,type:a}={}){return a&&(n=n||O(a),c=a),l(this,"_parse",(s,p,f)=>{let m=s(p,f);S(f);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let g={message:typeof n=="function"?n(p):n};return {success:false,error:g,errors:[g]}}),this}};return d.length>0?d.reduce((t,n)=>n(t,e,o)??t,r):r}var d=[];function x(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");d.push(e);}x((e,c,i)=>{if(i?.type==="array"){let u=e;u.min=function(o,{message:r}={}){return this.refine(t=>t.length>=o,{message:r||`Array must contain at least ${o} items.`})},u.max=function(o,{message:r}={}){return this.refine(t=>t.length<=o,{message:r||`Array must contain at most ${o} items.`})},u.length=function(o,{message:r}={}){return this.refine(t=>t.length===o,{message:r||`Array must contain exactly ${o} items.`})},u.nonEmpty=function({message:o}={}){return this.refine(r=>r.length>0,{message:o||"Array must not be empty."})},u.unique=function({message:o}={}){return this.refine(r=>{let t=new Set;try{return r.every(n=>{let a=JSON.stringify(n);return t.has(a)?!1:(t.add(a),!0)})}catch{return new Set(r).size===r.length}},{message:o||"Array items must be unique."})},u.sort=function(){return this.transform(o=>[...o].sort())},u.reverse=function(){return this.transform(o=>[...o].reverse())};}return e});exports.extend=x;exports.hookOriginal=l;exports.s=R;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-PHNKAD7Q.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-NCHMO7B3.mjs';
import'./chunk-ELVLLQRH.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-V2T3CZFC.mjs';

@@ -1,1 +0,1 @@

'use strict';var P={abortEarly:true};function y(r,o){if(!o)return r;let u=r?.cause?.key?`${o}.${r.cause.key}`:`${o}`;return {message:`Error parsing key "${u}": ${r.message}`,cause:{key:u}}}function O(r,o,u){!r.errors||r.errors.length===0||r.errors.forEach(a=>{let t=y(a,u);o.push(t);});}function d(r){return {...P,...r}}var $=r=>typeof r=="string"||r instanceof String,N=r=>typeof r=="number"||r instanceof Number,k=r=>r===true||r===false,w=r=>r instanceof Date&&!Number.isNaN(r.getTime()),E=r=>Array.isArray(r),T=r=>typeof r=="object"&&r!==null&&!Array.isArray(r),D={object(r,o){let u=S(T,{...o,type:"object"});return u._getDescription=()=>`object({ ${Object.entries(r).map(([t,n])=>`${t}: ${n._getDescription()}`).join(", ")} })`,h(u,"_parse",(a,t,n)=>{let e=a(t,n),{abortEarly:s}=d(n);if(e.success===false)return e;let c={},i=[];for(let m in r){let p=r[m]._parse(e.data[m],n);if(p.success)c[m]=p.data;else {if(p=p,s!==false){let f=y(p.error,m);return {success:false,error:f,errors:[f]}}O(p,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:c}}),u},string(r){return S($,{...r,type:"string"})},number(r){return S(N,{...r,type:"number"})},boolean(r){return S(k,{...r,type:"boolean"})},date(r){return S(w,{...r,type:"date"})},enum(r,o){let u=e=>r.includes(e),a=e=>`Invalid ${t} value. Expected ${r.map(s=>`"${s}"`).join(" | ")}, received "${e}".`,t="enum",n=S(u,{message:a,...o,type:t});return n._getDescription=()=>`enum(${r.map(e=>`"${e}"`).join(" | ")})`,n},array(r,o){let u=S(E,{...o,type:"array"});return u._getDescription=()=>`array(${r._getDescription()})`,h(u,"_parse",(a,t,n)=>{let e=a(t,n),{abortEarly:s}=d(n);if(e.success===false)return e;let c=[],i=[];for(let m=0;m<e.data.length;m++){let p=r._parse(e.data[m],n);if(p.success)c.push(p.data);else {if(p=p,s!==false){let f=y(p.error,m);return {success:false,error:f,errors:[f]}}O(p,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:c}}),u},any(){return S(()=>true)},preprocess(r,o){return h(o,"_parse",(u,a)=>(a=r(a),u(a))),o},union(r,o){return S(n=>{for(let e=0;e<r.length;e++){let s=r[e]._parse(n);if(s.success)return s}return false},{message:n=>`Invalid union value. Expected the value to match one of the schemas:${r.map((e,s)=>` ${s+1}. ${e._getDescription()}`).join(",")} but received "${typeof n}" with value: ${T(n)?JSON.stringify(n):`"${n}"`}`,...o,type:"union"})}};function x(r){return o=>`The value "${o}" must be type of ${r} but is type of "${typeof o}".`}function h(r,o,u){let a=r[o];r[o]=(...t)=>u(a,...t);}function S(r,{type:o="any",name:u,message:a}={}){a=a||x(o);let t={name:u,message:a,type:o},n={_getName(){return u},_getType(){return o},_getDescription(){return this._getName()??this._getType()},_parse(e,s){let c=r(e);if(c===true)return {success:true,data:e};if(typeof c=="object"&&c?.success===true)return c;let i={message:typeof a=="function"?a(e):a};return {success:false,error:i,errors:[i]}},parse(e,s){let c=n._parse(e,s);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(e,s){return n._parse(e,s)},transform(e){return h(this,"_parse",(s,c,i)=>{let m=s(c,i);return m.success&&(m.data=e(m.data)),m}),this},optional(){return h(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return h(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s===null&&(i.data=null,i.success=true),i}),this},nullish(){return h(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s==null&&(i.success=true,i.data=s),i}),this},default(e){return h(this,"_parse",(s,c,i)=>(c===void 0&&(c=e,c=typeof e=="function"?e():e),s(c,i))),this},pipe(e){return h(this,"_parse",(s,c,i)=>{let m=s(c,i);return m.success?e._parse(m.data,i):m}),this},refine(e,{message:s,type:c}={}){return c&&(s=s||x(c),o=c),h(this,"_parse",(i,m,p)=>{let f=i(m,p);d(p);if(!f.success)return f;let l=e(f.data);if(l===true||typeof l=="object"&&l?.success===true)return f;let b={message:typeof s=="function"?s(m):s};return {success:false,error:b,errors:[b]}}),this}};return g.length>0?g.reduce((e,s)=>s(e,r,t)??e,n):n}var g=[];function I(r){g.push(r);}I((r,o,u)=>{if(u?.type==="string"){let a=r;a.min=function(t,{message:n}={}){return this.refine(e=>e.length>=t,{message:n||(e=>`String must be at least ${t} characters long (received ${e.length} characters: "${e}")`)})},a.max=function(t,{message:n}={}){return this.refine(e=>e.length<=t,{message:n||(e=>`String must be at most ${t} characters long (received ${e.length} characters: "${e}")`)})},a.length=function(t,{message:n}={}){return this.refine(e=>e.length===t,{message:n||(e=>`String must be exactly ${t} characters long (received ${e.length} characters: "${e}")`)})},a.nonEmpty=function({message:t}={}){return this.refine(n=>n.length>0,{message:t||"String must not be empty (received empty string)"})},a.startsWith=function(t,{message:n}={}){return this.refine(e=>e.startsWith(t),{message:n||(e=>`String must start with "${t}" (received: "${e}")`)})},a.endsWith=function(t,{message:n}={}){return this.refine(e=>e.endsWith(t),{message:n||(e=>`String must end with "${t}" (received: "${e}")`)})},a.includes=function(t,{message:n}={}){return this.refine(e=>e.includes(t),{message:n||(e=>`String must include "${t}" (received: "${e}")`)})},a.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},a.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},a.trim=function(){return this.transform(t=>t.trim())},a.padStart=function(t,n=" "){return this.transform(e=>e.padStart(t,n))},a.padEnd=function(t,n=" "){return this.transform(e=>e.padEnd(t,n))},a.replace=function(t,n){return this.transform(e=>e.replace(t,n))};}return r});I((r,o,u)=>{if(u?.type==="number"){let a=r;a.min=function(t,{message:n}={}){return this.refine(e=>e>=t,{message:n||`Number must be greater than or equal to ${t}.`})},a.max=function(t,{message:n}={}){return this.refine(e=>e<=t,{message:n||`Number must be less than or equal to ${t}.`})},a.positive=function({message:t}={}){return this.refine(n=>n>0,{message:t||"Number must be positive."})},a.negative=function({message:t}={}){return this.refine(n=>n<0,{message:t||"Number must be negative."})},a.int=function({message:t}={}){return this.refine(n=>Number.isInteger(n),{message:t||"Number must be an integer."})},a.float=function({message:t}={}){return this.refine(n=>Number.isFinite(n)&&!Number.isInteger(n),{message:t||"Number must be a floating point (non-integer)."})},a.multipleOf=function(t,{message:n}={}){return this.refine(e=>e%t===0,{message:n||`Number must be a multiple of ${t}.`})},a.finite=function({message:t}={}){return this.refine(n=>Number.isFinite(n),{message:t||"Number must be finite."})};}return r});I((r,o,u)=>{if(u?.type==="array"){let a=r;a.min=function(t,{message:n}={}){return this.refine(e=>e.length>=t,{message:n||`Array must contain at least ${t} items.`})},a.max=function(t,{message:n}={}){return this.refine(e=>e.length<=t,{message:n||`Array must contain at most ${t} items.`})},a.length=function(t,{message:n}={}){return this.refine(e=>e.length===t,{message:n||`Array must contain exactly ${t} items.`})},a.nonEmpty=function({message:t}={}){return this.refine(n=>n.length>0,{message:t||"Array must not be empty."})},a.unique=function({message:t}={}){return this.refine(n=>{let e=new Set;try{return n.every(s=>{let c=JSON.stringify(s);return e.has(c)?!1:(e.add(c),!0)})}catch{return new Set(n).size===n.length}},{message:t||"Array items must be unique."})},a.sort=function(){return this.transform(t=>[...t].sort())},a.reverse=function(){return this.transform(t=>[...t].reverse())};}return r});exports.extend=I;exports.hookOriginal=h;exports.s=D;
'use strict';var w={abortEarly:true};function y(n,u){if(!u)return n;let o=n?.cause?.key?`${u}.${n.cause.key}`:`${u}`;return {message:`Error parsing key "${o}": ${n.message}`,cause:{key:o}}}function O(n,u,o){if(n.errors?.length)for(let a=0;a<n.errors.length;a++)u.push(y(n.errors[a],o));}function g(n){return {...w,...n}}var k=n=>typeof n=="string"||n instanceof String,P=n=>(typeof n=="number"||n instanceof Number)&&!Number.isNaN(n),$=n=>n===true||n===false,N=n=>n instanceof Date&&!Number.isNaN(n.getTime()),E=n=>Array.isArray(n),T=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),v={object(n,u){let o=h(T,{...u,type:"object"});return o._getDescription=()=>`object({ ${Object.entries(n).map(([t,r])=>`${t}: ${r._getDescription()}`).join(", ")} })`,S(o,"_parse",(a,t,r)=>{let e=a(t,r),{abortEarly:s}=g(r);if(e.success===false)return e;let c={},i=[];for(let m in n){let f=n[m]._parse(e.data[m],r);if(f.success)c[m]=f.data;else {if(f=f,s!==false){let p=y(f.error,m);return {success:false,error:p,errors:[p]}}O(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:c}}),o},string(n){return h(k,{...n,type:"string"})},number(n){return h(P,{...n,type:"number"})},boolean(n){return h($,{...n,type:"boolean"})},date(n){return h(N,{...n,type:"date"})},enum(n,u){let o=e=>n.includes(e),a=e=>`Invalid ${t} value. Expected ${n.map(s=>`"${s}"`).join(" | ")}, received "${e}".`,t="enum",r=h(o,{message:a,...u,type:t});return r._getDescription=()=>`enum(${n.map(e=>`"${e}"`).join(" | ")})`,r},array(n,u){let o=h(E,{...u,type:"array"});return o._getDescription=()=>`array(${n._getDescription()})`,S(o,"_parse",(a,t,r)=>{let e=a(t,r),{abortEarly:s}=g(r);if(e.success===false)return e;let c=[],i=[];for(let m=0;m<e.data.length;m++){let f=n._parse(e.data[m],r);if(f.success)c.push(f.data);else {if(f=f,s!==false){let p=y(f.error,m);return {success:false,error:p,errors:[p]}}O(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:c}}),o},any(){return h(()=>true)},preprocess(n,u){return S(u,"_parse",(o,a)=>(a=n(a),o(a))),u},union(n,u){return h(r=>{for(let e=0;e<n.length;e++){let s=n[e]._parse(r);if(s.success)return s}return false},{message:r=>`Invalid union value. Expected the value to match one of the schemas:${n.map((e,s)=>` ${s+1}. ${e._getDescription()}`).join(",")} but received "${typeof r}" with value: ${T(r)?JSON.stringify(r):`"${r}"`}`,...u,type:"union"})},literal(n,u){let t=h(r=>r===n,{message:r=>u?.message?typeof u.message=="function"?u.message(r):u.message:`Expected literal value "${n}", received "${r}"`,name:u?.name,type:"literal"});return t._getDescription=()=>`literal("${n}")`,t}};function x(n){return u=>`The value "${u}" must be type of ${n} but is type of "${typeof u}".`}function S(n,u,o){let a=n[u];n[u]=(...t)=>o(a,...t);}function h(n,{type:u="any",name:o,message:a}={}){a=a||x(u);let t={name:o,message:a,type:u},r={_getName(){return o},_getType(){return u},_getDescription(){return this._getName()??this._getType()},_parse(e,s){let c=n(e);if(c===true)return {success:true,data:e};if(typeof c=="object"&&c?.success===true)return c;let i={message:typeof a=="function"?a(e):a};return {success:false,error:i,errors:[i]}},parse(e,s){let c=r._parse(e,s);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(e,s){return r._parse(e,s)},transform(e){return S(this,"_parse",(s,c,i)=>{let m=s(c,i);return m.success&&(m.data=e(m.data)),m}),this},optional(){return S(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return S(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s===null&&(i.data=null,i.success=true),i}),this},nullish(){return S(this,"_parse",(e,s,c)=>{let i=e(s,c);return !i.success&&s==null&&(i.success=true,i.data=s),i}),this},default(e){return S(this,"_parse",(s,c,i)=>(c===void 0&&(c=typeof e=="function"?e():e),s(c,i))),this},pipe(e){return S(this,"_parse",(s,c,i)=>{let m=s(c,i);return m.success?e._parse(m.data,i):m}),this},refine(e,{message:s,type:c}={}){return c&&(s=s||x(c),u=c),S(this,"_parse",(i,m,f)=>{let p=i(m,f);g(f);if(!p.success)return p;let l=e(p.data);if(l===true||typeof l=="object"&&l?.success===true)return p;let b={message:typeof s=="function"?s(m):s};return {success:false,error:b,errors:[b]}}),this}};return d.length>0?d.reduce((e,s)=>s(e,n,t)??e,r):r}var d=[];function I(n){if(typeof n!="function")throw new TypeError("extend() requires a function argument");d.push(n);}I((n,u,o)=>{if(o?.type==="string"){let a=n;a.min=function(t,{message:r}={}){return this.refine(e=>e.length>=t,{message:r||(e=>`String must be at least ${t} characters long (received ${e.length} characters: "${e}")`)})},a.max=function(t,{message:r}={}){return this.refine(e=>e.length<=t,{message:r||(e=>`String must be at most ${t} characters long (received ${e.length} characters: "${e}")`)})},a.length=function(t,{message:r}={}){return this.refine(e=>e.length===t,{message:r||(e=>`String must be exactly ${t} characters long (received ${e.length} characters: "${e}")`)})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"String must not be empty (received empty string)"})},a.startsWith=function(t,{message:r}={}){return this.refine(e=>e.startsWith(t),{message:r||(e=>`String must start with "${t}" (received: "${e}")`)})},a.endsWith=function(t,{message:r}={}){return this.refine(e=>e.endsWith(t),{message:r||(e=>`String must end with "${t}" (received: "${e}")`)})},a.includes=function(t,{message:r}={}){return this.refine(e=>e.includes(t),{message:r||(e=>`String must include "${t}" (received: "${e}")`)})},a.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},a.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},a.trim=function(){return this.transform(t=>t.trim())},a.padStart=function(t,r=" "){return this.transform(e=>e.padStart(t,r))},a.padEnd=function(t,r=" "){return this.transform(e=>e.padEnd(t,r))},a.replace=function(t,r){return this.transform(e=>e.replace(t,r))};}return n});I((n,u,o)=>{if(o?.type==="number"){let a=n;a.min=function(t,{message:r}={}){return this.refine(e=>e>=t,{message:r||`Number must be greater than or equal to ${t}.`})},a.max=function(t,{message:r}={}){return this.refine(e=>e<=t,{message:r||`Number must be less than or equal to ${t}.`})},a.positive=function({message:t}={}){return this.refine(r=>r>0,{message:t||"Number must be positive."})},a.negative=function({message:t}={}){return this.refine(r=>r<0,{message:t||"Number must be negative."})},a.int=function({message:t}={}){return this.refine(r=>Number.isInteger(r),{message:t||"Number must be an integer."})},a.float=function({message:t}={}){return this.refine(r=>Number.isFinite(r)&&!Number.isInteger(r),{message:t||"Number must be a floating point (non-integer)."})},a.multipleOf=function(t,{message:r}={}){return this.refine(e=>e%t===0,{message:r||`Number must be a multiple of ${t}.`})},a.finite=function({message:t}={}){return this.refine(r=>Number.isFinite(r),{message:t||"Number must be finite."})};}return n});I((n,u,o)=>{if(o?.type==="array"){let a=n;a.min=function(t,{message:r}={}){return this.refine(e=>e.length>=t,{message:r||`Array must contain at least ${t} items.`})},a.max=function(t,{message:r}={}){return this.refine(e=>e.length<=t,{message:r||`Array must contain at most ${t} items.`})},a.length=function(t,{message:r}={}){return this.refine(e=>e.length===t,{message:r||`Array must contain exactly ${t} items.`})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"Array must not be empty."})},a.unique=function({message:t}={}){return this.refine(r=>{let e=new Set;try{return r.every(s=>{let c=JSON.stringify(s);return e.has(c)?!1:(e.add(c),!0)})}catch{return new Set(r).size===r.length}},{message:t||"Array items must be unique."})},a.sort=function(){return this.transform(t=>[...t].sort())},a.reverse=function(){return this.transform(t=>[...t].reverse())};}return n});exports.extend=I;exports.hookOriginal=S;exports.s=v;
import './string.mjs';
import './number.mjs';
import './array.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';
import './string.js';
import './number.js';
import './array.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';

@@ -1,1 +0,1 @@

import'./chunk-PHNKAD7Q.mjs';import'./chunk-SHVCROKM.mjs';import'./chunk-BV6SWQSH.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-NCHMO7B3.mjs';
import'./chunk-ELVLLQRH.mjs';import'./chunk-W2H6TLSH.mjs';import'./chunk-FEEE6IG6.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-V2T3CZFC.mjs';

@@ -1,1 +0,1 @@

'use strict';var P={abortEarly:true};function d(e,s){if(!s)return e;let o=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${o}": ${e.message}`,cause:{key:o}}}function b(e,s,o){!e.errors||e.errors.length===0||e.errors.forEach(i=>{let f=d(i,o);s.push(f);});}function y(e){return {...P,...e}}var x=e=>typeof e=="string"||e instanceof String,k=e=>typeof e=="number"||e instanceof Number,w=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R={object(e,s){let o=l(g,{...s,type:"object"});return o._getDescription=()=>`object({ ${Object.entries(e).map(([f,c])=>`${f}: ${c._getDescription()}`).join(", ")} })`,h(o,"_parse",(i,f,c)=>{let t=i(f,c),{abortEarly:r}=y(c);if(t.success===false)return t;let a={},n=[];for(let u in e){let p=e[u]._parse(t.data[u],c);if(p.success)a[u]=p.data;else {if(p=p,r!==false){let m=d(p.error,u);return {success:false,error:m,errors:[m]}}b(p,n,u);}}return n.length>0?{success:false,error:n[0],errors:n}:{success:true,data:a}}),o},string(e){return l(x,{...e,type:"string"})},number(e){return l(k,{...e,type:"number"})},boolean(e){return l(w,{...e,type:"boolean"})},date(e){return l(E,{...e,type:"date"})},enum(e,s){let o=t=>e.includes(t),i=t=>`Invalid ${f} value. Expected ${e.map(r=>`"${r}"`).join(" | ")}, received "${t}".`,f="enum",c=l(o,{message:i,...s,type:f});return c._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,c},array(e,s){let o=l(_,{...s,type:"array"});return o._getDescription=()=>`array(${e._getDescription()})`,h(o,"_parse",(i,f,c)=>{let t=i(f,c),{abortEarly:r}=y(c);if(t.success===false)return t;let a=[],n=[];for(let u=0;u<t.data.length;u++){let p=e._parse(t.data[u],c);if(p.success)a.push(p.data);else {if(p=p,r!==false){let m=d(p.error,u);return {success:false,error:m,errors:[m]}}b(p,n,u);}}return n.length>0?{success:false,error:n[0],errors:n}:{success:true,data:a}}),o},any(){return l(()=>true)},preprocess(e,s){return h(s,"_parse",(o,i)=>(i=e(i),o(i))),s},union(e,s){return l(c=>{for(let t=0;t<e.length;t++){let r=e[t]._parse(c);if(r.success)return r}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,r)=>` ${r+1}. ${t._getDescription()}`).join(",")} but received "${typeof c}" with value: ${g(c)?JSON.stringify(c):`"${c}"`}`,...s,type:"union"})}};function O(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function h(e,s,o){let i=e[s];e[s]=(...f)=>o(i,...f);}function l(e,{type:s="any",name:o,message:i}={}){i=i||O(s);let f={name:o,message:i,type:s},c={_getName(){return o},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(t,r){let a=e(t);if(a===true)return {success:true,data:t};if(typeof a=="object"&&a?.success===true)return a;let n={message:typeof i=="function"?i(t):i};return {success:false,error:n,errors:[n]}},parse(t,r){let a=c._parse(t,r);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(t,r){return c._parse(t,r)},transform(t){return h(this,"_parse",(r,a,n)=>{let u=r(a,n);return u.success&&(u.data=t(u.data)),u}),this},optional(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r===void 0&&(n.data=void 0,n.success=true),n}),this},nullable(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r===null&&(n.data=null,n.success=true),n}),this},nullish(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r==null&&(n.success=true,n.data=r),n}),this},default(t){return h(this,"_parse",(r,a,n)=>(a===void 0&&(a=t,a=typeof t=="function"?t():t),r(a,n))),this},pipe(t){return h(this,"_parse",(r,a,n)=>{let u=r(a,n);return u.success?t._parse(u.data,n):u}),this},refine(t,{message:r,type:a}={}){return a&&(r=r||O(a),s=a),h(this,"_parse",(n,u,p)=>{let m=n(u,p);y(p);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let T={message:typeof r=="function"?r(u):r};return {success:false,error:T,errors:[T]}}),this}};return S.length>0?S.reduce((t,r)=>r(t,e,f)??t,c):c}var S=[];function $(e){S.push(e);}exports.extend=$;exports.hookOriginal=h;exports.s=R;
'use strict';var k={abortEarly:true};function d(e,s){if(!s)return e;let i=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function T(e,s,i){if(e.errors?.length)for(let u=0;u<e.errors.length;u++)s.push(d(e.errors[u],i));}function y(e){return {...k,...e}}var x=e=>typeof e=="string"||e instanceof String,w=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),P=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),b=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),$={object(e,s){let i=l(b,{...s,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([p,c])=>`${p}: ${c._getDescription()}`).join(", ")} })`,h(i,"_parse",(u,p,c)=>{let t=u(p,c),{abortEarly:n}=y(c);if(t.success===false)return t;let a={},r=[];for(let o in e){let f=e[o]._parse(t.data[o],c);if(f.success)a[o]=f.data;else {if(f=f,n!==false){let m=d(f.error,o);return {success:false,error:m,errors:[m]}}T(f,r,o);}}return r.length>0?{success:false,error:r[0],errors:r}:{success:true,data:a}}),i},string(e){return l(x,{...e,type:"string"})},number(e){return l(w,{...e,type:"number"})},boolean(e){return l(P,{...e,type:"boolean"})},date(e){return l(E,{...e,type:"date"})},enum(e,s){let i=t=>e.includes(t),u=t=>`Invalid ${p} value. Expected ${e.map(n=>`"${n}"`).join(" | ")}, received "${t}".`,p="enum",c=l(i,{message:u,...s,type:p});return c._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,c},array(e,s){let i=l(_,{...s,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,h(i,"_parse",(u,p,c)=>{let t=u(p,c),{abortEarly:n}=y(c);if(t.success===false)return t;let a=[],r=[];for(let o=0;o<t.data.length;o++){let f=e._parse(t.data[o],c);if(f.success)a.push(f.data);else {if(f=f,n!==false){let m=d(f.error,o);return {success:false,error:m,errors:[m]}}T(f,r,o);}}return r.length>0?{success:false,error:r[0],errors:r}:{success:true,data:a}}),i},any(){return l(()=>true)},preprocess(e,s){return h(s,"_parse",(i,u)=>(u=e(u),i(u))),s},union(e,s){return l(c=>{for(let t=0;t<e.length;t++){let n=e[t]._parse(c);if(n.success)return n}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,n)=>` ${n+1}. ${t._getDescription()}`).join(",")} but received "${typeof c}" with value: ${b(c)?JSON.stringify(c):`"${c}"`}`,...s,type:"union"})},literal(e,s){let p=l(c=>c===e,{message:c=>s?.message?typeof s.message=="function"?s.message(c):s.message:`Expected literal value "${e}", received "${c}"`,name:s?.name,type:"literal"});return p._getDescription=()=>`literal("${e}")`,p}};function O(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function h(e,s,i){let u=e[s];e[s]=(...p)=>i(u,...p);}function l(e,{type:s="any",name:i,message:u}={}){u=u||O(s);let p={name:i,message:u,type:s},c={_getName(){return i},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(t,n){let a=e(t);if(a===true)return {success:true,data:t};if(typeof a=="object"&&a?.success===true)return a;let r={message:typeof u=="function"?u(t):u};return {success:false,error:r,errors:[r]}},parse(t,n){let a=c._parse(t,n);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(t,n){return c._parse(t,n)},transform(t){return h(this,"_parse",(n,a,r)=>{let o=n(a,r);return o.success&&(o.data=t(o.data)),o}),this},optional(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n===void 0&&(r.data=void 0,r.success=true),r}),this},nullable(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n===null&&(r.data=null,r.success=true),r}),this},nullish(){return h(this,"_parse",(t,n,a)=>{let r=t(n,a);return !r.success&&n==null&&(r.success=true,r.data=n),r}),this},default(t){return h(this,"_parse",(n,a,r)=>(a===void 0&&(a=typeof t=="function"?t():t),n(a,r))),this},pipe(t){return h(this,"_parse",(n,a,r)=>{let o=n(a,r);return o.success?t._parse(o.data,r):o}),this},refine(t,{message:n,type:a}={}){return a&&(n=n||O(a),s=a),h(this,"_parse",(r,o,f)=>{let m=r(o,f);y(f);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let g={message:typeof n=="function"?n(o):n};return {success:false,error:g,errors:[g]}}),this}};return S.length>0?S.reduce((t,n)=>n(t,e,p)??t,c):c}var S=[];function A(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");S.push(e);}exports.extend=A;exports.hookOriginal=h;exports.s=$;

@@ -36,2 +36,4 @@ type ErrorStructure = {

}
interface LiteralSchemaInterface<T extends string | number | boolean> extends SchemaInterface<T, T> {
}
interface UnionSchemaInterface<T extends Array<SchemaInterface<unknown, unknown>>> extends SchemaInterface<ReturnType<T[number]['parse']>, ReturnType<T[number]['parse']>> {

@@ -57,3 +59,3 @@ }

}
type SchemaType = StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
type SchemaType = LiteralSchemaInterface<string> | LiteralSchemaInterface<number> | LiteralSchemaInterface<boolean> | StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
type ErrorMessage = string | ((value: unknown) => string);

@@ -212,4 +214,19 @@ type ExtenderType = (inter: SchemaType, validation: Function, options?: {

union<T extends Array<SchemaType>>(definitions: T, options?: SchemaInterfaceOptions): UnionSchemaInterface<T>;
/**
* Creates a literal schema that only accepts a specific value.
*
* @param value - The exact value to match
* @param options - Optional configuration
* @returns Literal schema interface
*
* @example
* ```typescript
* const adminSchema = s.literal('admin');
* adminSchema.parse('admin'); // 'admin'
* adminSchema.parse('user'); // throws error
* ```
*/
literal<T extends string | number | boolean>(value: T, options?: SchemaInterfaceOptions): LiteralSchemaInterface<T>;
};
declare function hookOriginal<Input, Output>(object: SchemaInterface<Input, Output> | SchemaType, method: string, action: (original: Function, ...args: unknown[]) => InternalParseOutput<Output>): void;
declare function hookOriginal<Input, Output>(object: SchemaInterface<Input, Output> | SchemaType, method: keyof (SchemaInterface<Input, Output> | SchemaType), action: (original: Function, ...args: unknown[]) => InternalParseOutput<Output>): void;
/**

@@ -273,2 +290,2 @@ * Extends the schema system with custom validation methods.

export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type Infer, type Invalid, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, extend, hookOriginal, s };
export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, extend, hookOriginal, s };

@@ -36,2 +36,4 @@ type ErrorStructure = {

}
interface LiteralSchemaInterface<T extends string | number | boolean> extends SchemaInterface<T, T> {
}
interface UnionSchemaInterface<T extends Array<SchemaInterface<unknown, unknown>>> extends SchemaInterface<ReturnType<T[number]['parse']>, ReturnType<T[number]['parse']>> {

@@ -57,3 +59,3 @@ }

}
type SchemaType = StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
type SchemaType = LiteralSchemaInterface<string> | LiteralSchemaInterface<number> | LiteralSchemaInterface<boolean> | StringSchemaInterface | SchemaInterface<unknown, unknown> | SchemaInterface<string, string> | SchemaInterface<string, string | undefined> | SchemaInterface<string, string | null> | SchemaInterface<string, string | undefined | null> | ObjectSchemaInterface<Record<string, SchemaType>> | SchemaInterface<object, object> | SchemaInterface<object, object | undefined> | SchemaInterface<object, object | null> | SchemaInterface<object, object | undefined | null> | NumberSchemaInterface | SchemaInterface<number, number> | SchemaInterface<number, number | undefined> | SchemaInterface<number, number | null> | SchemaInterface<number, number | undefined | null> | BooleanSchemaInterface | SchemaInterface<boolean, boolean> | SchemaInterface<boolean, boolean | undefined> | SchemaInterface<boolean, boolean | null> | SchemaInterface<boolean, boolean | undefined | null> | DateSchemaInterface | SchemaInterface<Date, Date> | SchemaInterface<Date, Date | undefined> | SchemaInterface<Date, Date | null> | SchemaInterface<Date, Date | undefined | null> | EnumSchemaInterface<string> | UnionSchemaInterface<Array<SchemaInterface<unknown, unknown>>> | ArraySchemaInterface<StringSchemaInterface | ObjectSchemaInterface<Record<string, SchemaType>> | NumberSchemaInterface | BooleanSchemaInterface | DateSchemaInterface | EnumSchemaInterface<string>> | SchemaInterface<Array<unknown>, Array<unknown>> | SchemaInterface<Array<unknown>, Array<unknown> | undefined> | SchemaInterface<Array<unknown>, Array<unknown> | null> | SchemaInterface<Array<unknown>, Array<unknown> | undefined | null>;
type ErrorMessage = string | ((value: unknown) => string);

@@ -212,4 +214,19 @@ type ExtenderType = (inter: SchemaType, validation: Function, options?: {

union<T extends Array<SchemaType>>(definitions: T, options?: SchemaInterfaceOptions): UnionSchemaInterface<T>;
/**
* Creates a literal schema that only accepts a specific value.
*
* @param value - The exact value to match
* @param options - Optional configuration
* @returns Literal schema interface
*
* @example
* ```typescript
* const adminSchema = s.literal('admin');
* adminSchema.parse('admin'); // 'admin'
* adminSchema.parse('user'); // throws error
* ```
*/
literal<T extends string | number | boolean>(value: T, options?: SchemaInterfaceOptions): LiteralSchemaInterface<T>;
};
declare function hookOriginal<Input, Output>(object: SchemaInterface<Input, Output> | SchemaType, method: string, action: (original: Function, ...args: unknown[]) => InternalParseOutput<Output>): void;
declare function hookOriginal<Input, Output>(object: SchemaInterface<Input, Output> | SchemaType, method: keyof (SchemaInterface<Input, Output> | SchemaType), action: (original: Function, ...args: unknown[]) => InternalParseOutput<Output>): void;
/**

@@ -273,2 +290,2 @@ * Extends the schema system with custom validation methods.

export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type Infer, type Invalid, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, extend, hookOriginal, s };
export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, extend, hookOriginal, s };

@@ -1,1 +0,1 @@

export{c as extend,b as hookOriginal,a as s}from'./chunk-NCHMO7B3.mjs';
export{c as extend,b as hookOriginal,a as s}from'./chunk-V2T3CZFC.mjs';

@@ -1,1 +0,1 @@

'use strict';var P={abortEarly:true};function S(e,o){if(!o)return e;let i=e?.cause?.key?`${o}.${e.cause.key}`:`${o}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function g(e,o,i){!e.errors||e.errors.length===0||e.errors.forEach(u=>{let c=S(u,i);o.push(c);});}function d(e){return {...P,...e}}var N=e=>typeof e=="string"||e instanceof String,k=e=>typeof e=="number"||e instanceof Number,w=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),O=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),A={object(e,o){let i=I(O,{...o,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([c,r])=>`${c}: ${r._getDescription()}`).join(", ")} })`,h(i,"_parse",(u,c,r)=>{let t=u(c,r),{abortEarly:n}=d(r);if(t.success===false)return t;let s={},a=[];for(let p in e){let f=e[p]._parse(t.data[p],r);if(f.success)s[p]=f.data;else {if(f=f,n!==false){let m=S(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:s}}),i},string(e){return I(N,{...e,type:"string"})},number(e){return I(k,{...e,type:"number"})},boolean(e){return I(w,{...e,type:"boolean"})},date(e){return I(E,{...e,type:"date"})},enum(e,o){let i=t=>e.includes(t),u=t=>`Invalid ${c} value. Expected ${e.map(n=>`"${n}"`).join(" | ")}, received "${t}".`,c="enum",r=I(i,{message:u,...o,type:c});return r._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,r},array(e,o){let i=I(_,{...o,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,h(i,"_parse",(u,c,r)=>{let t=u(c,r),{abortEarly:n}=d(r);if(t.success===false)return t;let s=[],a=[];for(let p=0;p<t.data.length;p++){let f=e._parse(t.data[p],r);if(f.success)s.push(f.data);else {if(f=f,n!==false){let m=S(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:s}}),i},any(){return I(()=>true)},preprocess(e,o){return h(o,"_parse",(i,u)=>(u=e(u),i(u))),o},union(e,o){return I(r=>{for(let t=0;t<e.length;t++){let n=e[t]._parse(r);if(n.success)return n}return false},{message:r=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,n)=>` ${n+1}. ${t._getDescription()}`).join(",")} but received "${typeof r}" with value: ${O(r)?JSON.stringify(r):`"${r}"`}`,...o,type:"union"})}};function T(e){return o=>`The value "${o}" must be type of ${e} but is type of "${typeof o}".`}function h(e,o,i){let u=e[o];e[o]=(...c)=>i(u,...c);}function I(e,{type:o="any",name:i,message:u}={}){u=u||T(o);let c={name:i,message:u,type:o},r={_getName(){return i},_getType(){return o},_getDescription(){return this._getName()??this._getType()},_parse(t,n){let s=e(t);if(s===true)return {success:true,data:t};if(typeof s=="object"&&s?.success===true)return s;let a={message:typeof u=="function"?u(t):u};return {success:false,error:a,errors:[a]}},parse(t,n){let s=r._parse(t,n);if(!s.success)throw s=s,new Error(s.error.message,{cause:s.error.cause});return s.data},safeParse(t,n){return r._parse(t,n)},transform(t){return h(this,"_parse",(n,s,a)=>{let p=n(s,a);return p.success&&(p.data=t(p.data)),p}),this},optional(){return h(this,"_parse",(t,n,s)=>{let a=t(n,s);return !a.success&&n===void 0&&(a.data=void 0,a.success=true),a}),this},nullable(){return h(this,"_parse",(t,n,s)=>{let a=t(n,s);return !a.success&&n===null&&(a.data=null,a.success=true),a}),this},nullish(){return h(this,"_parse",(t,n,s)=>{let a=t(n,s);return !a.success&&n==null&&(a.success=true,a.data=n),a}),this},default(t){return h(this,"_parse",(n,s,a)=>(s===void 0&&(s=t,s=typeof t=="function"?t():t),n(s,a))),this},pipe(t){return h(this,"_parse",(n,s,a)=>{let p=n(s,a);return p.success?t._parse(p.data,a):p}),this},refine(t,{message:n,type:s}={}){return s&&(n=n||T(s),o=s),h(this,"_parse",(a,p,f)=>{let m=a(p,f);d(f);if(!m.success)return m;let l=t(m.data);if(l===true||typeof l=="object"&&l?.success===true)return m;let b={message:typeof n=="function"?n(p):n};return {success:false,error:b,errors:[b]}}),this}};return y.length>0?y.reduce((t,n)=>n(t,e,c)??t,r):r}var y=[];function x(e){y.push(e);}x((e,o,i)=>{if(i?.type==="number"){let u=e;u.min=function(c,{message:r}={}){return this.refine(t=>t>=c,{message:r||`Number must be greater than or equal to ${c}.`})},u.max=function(c,{message:r}={}){return this.refine(t=>t<=c,{message:r||`Number must be less than or equal to ${c}.`})},u.positive=function({message:c}={}){return this.refine(r=>r>0,{message:c||"Number must be positive."})},u.negative=function({message:c}={}){return this.refine(r=>r<0,{message:c||"Number must be negative."})},u.int=function({message:c}={}){return this.refine(r=>Number.isInteger(r),{message:c||"Number must be an integer."})},u.float=function({message:c}={}){return this.refine(r=>Number.isFinite(r)&&!Number.isInteger(r),{message:c||"Number must be a floating point (non-integer)."})},u.multipleOf=function(c,{message:r}={}){return this.refine(t=>t%c===0,{message:r||`Number must be a multiple of ${c}.`})},u.finite=function({message:c}={}){return this.refine(r=>Number.isFinite(r),{message:c||"Number must be finite."})};}return e});exports.extend=x;exports.hookOriginal=h;exports.s=A;
'use strict';var k={abortEarly:true};function S(e,u){if(!u)return e;let i=e?.cause?.key?`${u}.${e.cause.key}`:`${u}`;return {message:`Error parsing key "${i}": ${e.message}`,cause:{key:i}}}function g(e,u,i){if(e.errors?.length)for(let o=0;o<e.errors.length;o++)u.push(S(e.errors[o],i));}function d(e){return {...k,...e}}var w=e=>typeof e=="string"||e instanceof String,P=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),N=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),O=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R={object(e,u){let i=h(O,{...u,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(e).map(([s,n])=>`${s}: ${n._getDescription()}`).join(", ")} })`,l(i,"_parse",(o,s,n)=>{let t=o(s,n),{abortEarly:r}=d(n);if(t.success===false)return t;let c={},a=[];for(let p in e){let f=e[p]._parse(t.data[p],n);if(f.success)c[p]=f.data;else {if(f=f,r!==false){let m=S(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:c}}),i},string(e){return h(w,{...e,type:"string"})},number(e){return h(P,{...e,type:"number"})},boolean(e){return h(N,{...e,type:"boolean"})},date(e){return h(E,{...e,type:"date"})},enum(e,u){let i=t=>e.includes(t),o=t=>`Invalid ${s} value. Expected ${e.map(r=>`"${r}"`).join(" | ")}, received "${t}".`,s="enum",n=h(i,{message:o,...u,type:s});return n._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,n},array(e,u){let i=h(_,{...u,type:"array"});return i._getDescription=()=>`array(${e._getDescription()})`,l(i,"_parse",(o,s,n)=>{let t=o(s,n),{abortEarly:r}=d(n);if(t.success===false)return t;let c=[],a=[];for(let p=0;p<t.data.length;p++){let f=e._parse(t.data[p],n);if(f.success)c.push(f.data);else {if(f=f,r!==false){let m=S(f.error,p);return {success:false,error:m,errors:[m]}}g(f,a,p);}}return a.length>0?{success:false,error:a[0],errors:a}:{success:true,data:c}}),i},any(){return h(()=>true)},preprocess(e,u){return l(u,"_parse",(i,o)=>(o=e(o),i(o))),u},union(e,u){return h(n=>{for(let t=0;t<e.length;t++){let r=e[t]._parse(n);if(r.success)return r}return false},{message:n=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,r)=>` ${r+1}. ${t._getDescription()}`).join(",")} but received "${typeof n}" with value: ${O(n)?JSON.stringify(n):`"${n}"`}`,...u,type:"union"})},literal(e,u){let s=h(n=>n===e,{message:n=>u?.message?typeof u.message=="function"?u.message(n):u.message:`Expected literal value "${e}", received "${n}"`,name:u?.name,type:"literal"});return s._getDescription=()=>`literal("${e}")`,s}};function T(e){return u=>`The value "${u}" must be type of ${e} but is type of "${typeof u}".`}function l(e,u,i){let o=e[u];e[u]=(...s)=>i(o,...s);}function h(e,{type:u="any",name:i,message:o}={}){o=o||T(u);let s={name:i,message:o,type:u},n={_getName(){return i},_getType(){return u},_getDescription(){return this._getName()??this._getType()},_parse(t,r){let c=e(t);if(c===true)return {success:true,data:t};if(typeof c=="object"&&c?.success===true)return c;let a={message:typeof o=="function"?o(t):o};return {success:false,error:a,errors:[a]}},parse(t,r){let c=n._parse(t,r);if(!c.success)throw c=c,new Error(c.error.message,{cause:c.error.cause});return c.data},safeParse(t,r){return n._parse(t,r)},transform(t){return l(this,"_parse",(r,c,a)=>{let p=r(c,a);return p.success&&(p.data=t(p.data)),p}),this},optional(){return l(this,"_parse",(t,r,c)=>{let a=t(r,c);return !a.success&&r===void 0&&(a.data=void 0,a.success=true),a}),this},nullable(){return l(this,"_parse",(t,r,c)=>{let a=t(r,c);return !a.success&&r===null&&(a.data=null,a.success=true),a}),this},nullish(){return l(this,"_parse",(t,r,c)=>{let a=t(r,c);return !a.success&&r==null&&(a.success=true,a.data=r),a}),this},default(t){return l(this,"_parse",(r,c,a)=>(c===void 0&&(c=typeof t=="function"?t():t),r(c,a))),this},pipe(t){return l(this,"_parse",(r,c,a)=>{let p=r(c,a);return p.success?t._parse(p.data,a):p}),this},refine(t,{message:r,type:c}={}){return c&&(r=r||T(c),u=c),l(this,"_parse",(a,p,f)=>{let m=a(p,f);d(f);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let b={message:typeof r=="function"?r(p):r};return {success:false,error:b,errors:[b]}}),this}};return y.length>0?y.reduce((t,r)=>r(t,e,s)??t,n):n}var y=[];function x(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");y.push(e);}x((e,u,i)=>{if(i?.type==="number"){let o=e;o.min=function(s,{message:n}={}){return this.refine(t=>t>=s,{message:n||`Number must be greater than or equal to ${s}.`})},o.max=function(s,{message:n}={}){return this.refine(t=>t<=s,{message:n||`Number must be less than or equal to ${s}.`})},o.positive=function({message:s}={}){return this.refine(n=>n>0,{message:s||"Number must be positive."})},o.negative=function({message:s}={}){return this.refine(n=>n<0,{message:s||"Number must be negative."})},o.int=function({message:s}={}){return this.refine(n=>Number.isInteger(n),{message:s||"Number must be an integer."})},o.float=function({message:s}={}){return this.refine(n=>Number.isFinite(n)&&!Number.isInteger(n),{message:s||"Number must be a floating point (non-integer)."})},o.multipleOf=function(s,{message:n}={}){return this.refine(t=>t%s===0,{message:n||`Number must be a multiple of ${s}.`})},o.finite=function({message:s}={}){return this.refine(n=>Number.isFinite(n),{message:s||"Number must be finite."})};}return e});exports.extend=x;exports.hookOriginal=l;exports.s=R;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-SHVCROKM.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-NCHMO7B3.mjs';
import'./chunk-W2H6TLSH.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-V2T3CZFC.mjs';

@@ -1,1 +0,1 @@

'use strict';var P={abortEarly:true};function I(t,o){if(!o)return t;let i=t?.cause?.key?`${o}.${t.cause.key}`:`${o}`;return {message:`Error parsing key "${i}": ${t.message}`,cause:{key:i}}}function O(t,o,i){!t.errors||t.errors.length===0||t.errors.forEach(c=>{let r=I(c,i);o.push(r);});}function d(t){return {...P,...t}}var k=t=>typeof t=="string"||t instanceof String,w=t=>typeof t=="number"||t instanceof Number,E=t=>t===true||t===false,$=t=>t instanceof Date&&!Number.isNaN(t.getTime()),_=t=>Array.isArray(t),b=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),A={object(t,o){let i=S(b,{...o,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(t).map(([r,n])=>`${r}: ${n._getDescription()}`).join(", ")} })`,h(i,"_parse",(c,r,n)=>{let e=c(r,n),{abortEarly:a}=d(n);if(e.success===false)return e;let u={},s=[];for(let p in t){let f=t[p]._parse(e.data[p],n);if(f.success)u[p]=f.data;else {if(f=f,a!==false){let m=I(f.error,p);return {success:false,error:m,errors:[m]}}O(f,s,p);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),i},string(t){return S(k,{...t,type:"string"})},number(t){return S(w,{...t,type:"number"})},boolean(t){return S(E,{...t,type:"boolean"})},date(t){return S($,{...t,type:"date"})},enum(t,o){let i=e=>t.includes(e),c=e=>`Invalid ${r} value. Expected ${t.map(a=>`"${a}"`).join(" | ")}, received "${e}".`,r="enum",n=S(i,{message:c,...o,type:r});return n._getDescription=()=>`enum(${t.map(e=>`"${e}"`).join(" | ")})`,n},array(t,o){let i=S(_,{...o,type:"array"});return i._getDescription=()=>`array(${t._getDescription()})`,h(i,"_parse",(c,r,n)=>{let e=c(r,n),{abortEarly:a}=d(n);if(e.success===false)return e;let u=[],s=[];for(let p=0;p<e.data.length;p++){let f=t._parse(e.data[p],n);if(f.success)u.push(f.data);else {if(f=f,a!==false){let m=I(f.error,p);return {success:false,error:m,errors:[m]}}O(f,s,p);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),i},any(){return S(()=>true)},preprocess(t,o){return h(o,"_parse",(i,c)=>(c=t(c),i(c))),o},union(t,o){return S(n=>{for(let e=0;e<t.length;e++){let a=t[e]._parse(n);if(a.success)return a}return false},{message:n=>`Invalid union value. Expected the value to match one of the schemas:${t.map((e,a)=>` ${a+1}. ${e._getDescription()}`).join(",")} but received "${typeof n}" with value: ${b(n)?JSON.stringify(n):`"${n}"`}`,...o,type:"union"})}};function T(t){return o=>`The value "${o}" must be type of ${t} but is type of "${typeof o}".`}function h(t,o,i){let c=t[o];t[o]=(...r)=>i(c,...r);}function S(t,{type:o="any",name:i,message:c}={}){c=c||T(o);let r={name:i,message:c,type:o},n={_getName(){return i},_getType(){return o},_getDescription(){return this._getName()??this._getType()},_parse(e,a){let u=t(e);if(u===true)return {success:true,data:e};if(typeof u=="object"&&u?.success===true)return u;let s={message:typeof c=="function"?c(e):c};return {success:false,error:s,errors:[s]}},parse(e,a){let u=n._parse(e,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(e,a){return n._parse(e,a)},transform(e){return h(this,"_parse",(a,u,s)=>{let p=a(u,s);return p.success&&(p.data=e(p.data)),p}),this},optional(){return h(this,"_parse",(e,a,u)=>{let s=e(a,u);return !s.success&&a===void 0&&(s.data=void 0,s.success=true),s}),this},nullable(){return h(this,"_parse",(e,a,u)=>{let s=e(a,u);return !s.success&&a===null&&(s.data=null,s.success=true),s}),this},nullish(){return h(this,"_parse",(e,a,u)=>{let s=e(a,u);return !s.success&&a==null&&(s.success=true,s.data=a),s}),this},default(e){return h(this,"_parse",(a,u,s)=>(u===void 0&&(u=e,u=typeof e=="function"?e():e),a(u,s))),this},pipe(e){return h(this,"_parse",(a,u,s)=>{let p=a(u,s);return p.success?e._parse(p.data,s):p}),this},refine(e,{message:a,type:u}={}){return u&&(a=a||T(u),o=u),h(this,"_parse",(s,p,f)=>{let m=s(p,f);d(f);if(!m.success)return m;let l=e(m.data);if(l===true||typeof l=="object"&&l?.success===true)return m;let g={message:typeof a=="function"?a(p):a};return {success:false,error:g,errors:[g]}}),this}};return y.length>0?y.reduce((e,a)=>a(e,t,r)??e,n):n}var y=[];function x(t){y.push(t);}x((t,o,i)=>{if(i?.type==="string"){let c=t;c.min=function(r,{message:n}={}){return this.refine(e=>e.length>=r,{message:n||(e=>`String must be at least ${r} characters long (received ${e.length} characters: "${e}")`)})},c.max=function(r,{message:n}={}){return this.refine(e=>e.length<=r,{message:n||(e=>`String must be at most ${r} characters long (received ${e.length} characters: "${e}")`)})},c.length=function(r,{message:n}={}){return this.refine(e=>e.length===r,{message:n||(e=>`String must be exactly ${r} characters long (received ${e.length} characters: "${e}")`)})},c.nonEmpty=function({message:r}={}){return this.refine(n=>n.length>0,{message:r||"String must not be empty (received empty string)"})},c.startsWith=function(r,{message:n}={}){return this.refine(e=>e.startsWith(r),{message:n||(e=>`String must start with "${r}" (received: "${e}")`)})},c.endsWith=function(r,{message:n}={}){return this.refine(e=>e.endsWith(r),{message:n||(e=>`String must end with "${r}" (received: "${e}")`)})},c.includes=function(r,{message:n}={}){return this.refine(e=>e.includes(r),{message:n||(e=>`String must include "${r}" (received: "${e}")`)})},c.toLowerCase=function(){return this.transform(r=>r.toLowerCase())},c.toUpperCase=function(){return this.transform(r=>r.toUpperCase())},c.trim=function(){return this.transform(r=>r.trim())},c.padStart=function(r,n=" "){return this.transform(e=>e.padStart(r,n))},c.padEnd=function(r,n=" "){return this.transform(e=>e.padEnd(r,n))},c.replace=function(r,n){return this.transform(e=>e.replace(r,n))};}return t});exports.extend=x;exports.hookOriginal=h;exports.s=A;
'use strict';var k={abortEarly:true};function I(t,o){if(!o)return t;let i=t?.cause?.key?`${o}.${t.cause.key}`:`${o}`;return {message:`Error parsing key "${i}": ${t.message}`,cause:{key:i}}}function b(t,o,i){if(t.errors?.length)for(let s=0;s<t.errors.length;s++)o.push(I(t.errors[s],i));}function d(t){return {...k,...t}}var w=t=>typeof t=="string"||t instanceof String,P=t=>(typeof t=="number"||t instanceof Number)&&!Number.isNaN(t),$=t=>t===true||t===false,E=t=>t instanceof Date&&!Number.isNaN(t.getTime()),_=t=>Array.isArray(t),T=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),A={object(t,o){let i=h(T,{...o,type:"object"});return i._getDescription=()=>`object({ ${Object.entries(t).map(([r,n])=>`${r}: ${n._getDescription()}`).join(", ")} })`,l(i,"_parse",(s,r,n)=>{let e=s(r,n),{abortEarly:a}=d(n);if(e.success===false)return e;let u={},c=[];for(let p in t){let f=t[p]._parse(e.data[p],n);if(f.success)u[p]=f.data;else {if(f=f,a!==false){let m=I(f.error,p);return {success:false,error:m,errors:[m]}}b(f,c,p);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),i},string(t){return h(w,{...t,type:"string"})},number(t){return h(P,{...t,type:"number"})},boolean(t){return h($,{...t,type:"boolean"})},date(t){return h(E,{...t,type:"date"})},enum(t,o){let i=e=>t.includes(e),s=e=>`Invalid ${r} value. Expected ${t.map(a=>`"${a}"`).join(" | ")}, received "${e}".`,r="enum",n=h(i,{message:s,...o,type:r});return n._getDescription=()=>`enum(${t.map(e=>`"${e}"`).join(" | ")})`,n},array(t,o){let i=h(_,{...o,type:"array"});return i._getDescription=()=>`array(${t._getDescription()})`,l(i,"_parse",(s,r,n)=>{let e=s(r,n),{abortEarly:a}=d(n);if(e.success===false)return e;let u=[],c=[];for(let p=0;p<e.data.length;p++){let f=t._parse(e.data[p],n);if(f.success)u.push(f.data);else {if(f=f,a!==false){let m=I(f.error,p);return {success:false,error:m,errors:[m]}}b(f,c,p);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),i},any(){return h(()=>true)},preprocess(t,o){return l(o,"_parse",(i,s)=>(s=t(s),i(s))),o},union(t,o){return h(n=>{for(let e=0;e<t.length;e++){let a=t[e]._parse(n);if(a.success)return a}return false},{message:n=>`Invalid union value. Expected the value to match one of the schemas:${t.map((e,a)=>` ${a+1}. ${e._getDescription()}`).join(",")} but received "${typeof n}" with value: ${T(n)?JSON.stringify(n):`"${n}"`}`,...o,type:"union"})},literal(t,o){let r=h(n=>n===t,{message:n=>o?.message?typeof o.message=="function"?o.message(n):o.message:`Expected literal value "${t}", received "${n}"`,name:o?.name,type:"literal"});return r._getDescription=()=>`literal("${t}")`,r}};function O(t){return o=>`The value "${o}" must be type of ${t} but is type of "${typeof o}".`}function l(t,o,i){let s=t[o];t[o]=(...r)=>i(s,...r);}function h(t,{type:o="any",name:i,message:s}={}){s=s||O(o);let r={name:i,message:s,type:o},n={_getName(){return i},_getType(){return o},_getDescription(){return this._getName()??this._getType()},_parse(e,a){let u=t(e);if(u===true)return {success:true,data:e};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof s=="function"?s(e):s};return {success:false,error:c,errors:[c]}},parse(e,a){let u=n._parse(e,a);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(e,a){return n._parse(e,a)},transform(e){return l(this,"_parse",(a,u,c)=>{let p=a(u,c);return p.success&&(p.data=e(p.data)),p}),this},optional(){return l(this,"_parse",(e,a,u)=>{let c=e(a,u);return !c.success&&a===void 0&&(c.data=void 0,c.success=true),c}),this},nullable(){return l(this,"_parse",(e,a,u)=>{let c=e(a,u);return !c.success&&a===null&&(c.data=null,c.success=true),c}),this},nullish(){return l(this,"_parse",(e,a,u)=>{let c=e(a,u);return !c.success&&a==null&&(c.success=true,c.data=a),c}),this},default(e){return l(this,"_parse",(a,u,c)=>(u===void 0&&(u=typeof e=="function"?e():e),a(u,c))),this},pipe(e){return l(this,"_parse",(a,u,c)=>{let p=a(u,c);return p.success?e._parse(p.data,c):p}),this},refine(e,{message:a,type:u}={}){return u&&(a=a||O(u),o=u),l(this,"_parse",(c,p,f)=>{let m=c(p,f);d(f);if(!m.success)return m;let S=e(m.data);if(S===true||typeof S=="object"&&S?.success===true)return m;let y={message:typeof a=="function"?a(p):a};return {success:false,error:y,errors:[y]}}),this}};return g.length>0?g.reduce((e,a)=>a(e,t,r)??e,n):n}var g=[];function x(t){if(typeof t!="function")throw new TypeError("extend() requires a function argument");g.push(t);}x((t,o,i)=>{if(i?.type==="string"){let s=t;s.min=function(r,{message:n}={}){return this.refine(e=>e.length>=r,{message:n||(e=>`String must be at least ${r} characters long (received ${e.length} characters: "${e}")`)})},s.max=function(r,{message:n}={}){return this.refine(e=>e.length<=r,{message:n||(e=>`String must be at most ${r} characters long (received ${e.length} characters: "${e}")`)})},s.length=function(r,{message:n}={}){return this.refine(e=>e.length===r,{message:n||(e=>`String must be exactly ${r} characters long (received ${e.length} characters: "${e}")`)})},s.nonEmpty=function({message:r}={}){return this.refine(n=>n.length>0,{message:r||"String must not be empty (received empty string)"})},s.startsWith=function(r,{message:n}={}){return this.refine(e=>e.startsWith(r),{message:n||(e=>`String must start with "${r}" (received: "${e}")`)})},s.endsWith=function(r,{message:n}={}){return this.refine(e=>e.endsWith(r),{message:n||(e=>`String must end with "${r}" (received: "${e}")`)})},s.includes=function(r,{message:n}={}){return this.refine(e=>e.includes(r),{message:n||(e=>`String must include "${r}" (received: "${e}")`)})},s.toLowerCase=function(){return this.transform(r=>r.toLowerCase())},s.toUpperCase=function(){return this.transform(r=>r.toUpperCase())},s.trim=function(){return this.transform(r=>r.trim())},s.padStart=function(r,n=" "){return this.transform(e=>e.padStart(r,n))},s.padEnd=function(r,n=" "){return this.transform(e=>e.padEnd(r,n))},s.replace=function(r,n){return this.transform(e=>e.replace(r,n))};}return t});exports.extend=x;exports.hookOriginal=l;exports.s=A;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, extend, hookOriginal, s } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-BV6SWQSH.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-NCHMO7B3.mjs';
import'./chunk-FEEE6IG6.mjs';export{c as extend,b as hookOriginal,a as s}from'./chunk-V2T3CZFC.mjs';
{
"name": "@esmj/schema",
"version": "0.6.0",
"version": "0.7.0",
"description": "Tiny extendable package for schema validation.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -429,2 +429,3 @@ # Schema

- `s.array(def)` - Array validation
- `s.literal(value)` - Literal value validation
- `s.enum(values)` - Enum validation

@@ -633,2 +634,61 @@ - `s.union(schemas)` - Union validation

#### `s.literal(value, options?)`
Creates a literal schema that validates against an exact value. The value can be a string, number, or boolean. This is useful for discriminated unions, API response types, and strict value validation. You can optionally pass `options` to customize error messages.
- **`message`**: Can be either a constant string or a function `(value) => string`.
```typescript
// String literal
const adminSchema = s.literal('admin');
adminSchema.parse('admin'); // ✅ 'admin'
adminSchema.parse('user'); // ❌ throws error
// Number literal
const statusCode = s.literal(200);
statusCode.parse(200); // ✅ 200
statusCode.parse(404); // ❌ throws error
// Boolean literal
const enabled = s.literal(true);
enabled.parse(true); // ✅ true
enabled.parse(false); // ❌ throws error
// Custom error message
const typeSchema = s.literal('success', {
message: 'Response type must be "success"',
});
// Custom error function
const versionSchema = s.literal(1, {
message: (value) => `API version must be 1, received ${value}`,
});
// Discriminated unions with literal
const responseSchema = s.union([
s.object({
type: s.literal('success'),
data: s.string(),
}),
s.object({
type: s.literal('error'),
error: s.string(),
}),
]);
// Using multiple literals in union (similar to enum but with type inference)
const roleSchema = s.union([
s.literal('admin'),
s.literal('user'),
s.literal('guest'),
]);
```
**Common Use Cases:**
- **Discriminated Unions**: Use literal types to distinguish between different object shapes
- **API Response Types**: Validate exact status codes or response types
- **Configuration Flags**: Validate boolean flags or specific string values
- **Type Guards**: Create strict type validation for specific values
#### `s.union(definitions, options?)`

@@ -1144,3 +1204,3 @@

The `examples/` folder contains comprehensive, runnable examples demonstrating various use cases:
The `examples/` folder contains comprehensive, runnable examples demonstrating various use cases. See the [examples README](examples/README.md) for detailed documentation.

@@ -1193,2 +1253,18 @@ ### Basic Usage (`examples/basic-usage.ts`)

### Registration Form (`examples/registration-form.ts`)
Complete user registration form validation with email and phone number validation:
- Username validation with pattern matching
- Email validation using custom extension
- International phone number validation
- Password strength requirements
- Password confirmation matching
- Age verification (18+)
- Terms acceptance validation
- Error collection with `abortEarly: false`
```bash
node --experimental-strip-types examples/registration-form.ts
```
**To run all examples:**

@@ -1202,3 +1278,14 @@

node --experimental-strip-types examples/custom-extensions.ts
node --experimental-strip-types examples/registration-form.ts
# OR using npm scripts from examples folder
cd examples
npm install
npm run basic
npm run custom
npm run advanced
npm run extensions
npm run registration
npm run all # Run all examples
# OR using tsx (requires installation)

@@ -1210,2 +1297,3 @@ npm install -g tsx # If not already installed

npx tsx examples/custom-extensions.ts
npx tsx examples/registration-form.ts
```

@@ -1212,0 +1300,0 @@ ## Migration Guide

import {c}from'./chunk-NCHMO7B3.mjs';c((i,s,c)=>{if(c?.type==="string"){let r=i;r.min=function(t,{message:n}={}){return this.refine(e=>e.length>=t,{message:n||(e=>`String must be at least ${t} characters long (received ${e.length} characters: "${e}")`)})},r.max=function(t,{message:n}={}){return this.refine(e=>e.length<=t,{message:n||(e=>`String must be at most ${t} characters long (received ${e.length} characters: "${e}")`)})},r.length=function(t,{message:n}={}){return this.refine(e=>e.length===t,{message:n||(e=>`String must be exactly ${t} characters long (received ${e.length} characters: "${e}")`)})},r.nonEmpty=function({message:t}={}){return this.refine(n=>n.length>0,{message:t||"String must not be empty (received empty string)"})},r.startsWith=function(t,{message:n}={}){return this.refine(e=>e.startsWith(t),{message:n||(e=>`String must start with "${t}" (received: "${e}")`)})},r.endsWith=function(t,{message:n}={}){return this.refine(e=>e.endsWith(t),{message:n||(e=>`String must end with "${t}" (received: "${e}")`)})},r.includes=function(t,{message:n}={}){return this.refine(e=>e.includes(t),{message:n||(e=>`String must include "${t}" (received: "${e}")`)})},r.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},r.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},r.trim=function(){return this.transform(t=>t.trim())},r.padStart=function(t,n=" "){return this.transform(e=>e.padStart(t,n))},r.padEnd=function(t,n=" "){return this.transform(e=>e.padEnd(t,n))},r.replace=function(t,n){return this.transform(e=>e.replace(t,n))};}return i});
var P={abortEarly:true};function d(e,s){if(!s)return e;let o=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${o}": ${e.message}`,cause:{key:o}}}function b(e,s,o){!e.errors||e.errors.length===0||e.errors.forEach(i=>{let f=d(i,o);s.push(f);});}function y(e){return {...P,...e}}var x=e=>typeof e=="string"||e instanceof String,k=e=>typeof e=="number"||e instanceof Number,w=e=>e===true||e===false,E=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_=e=>Array.isArray(e),g=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R={object(e,s){let o=l(g,{...s,type:"object"});return o._getDescription=()=>`object({ ${Object.entries(e).map(([f,c])=>`${f}: ${c._getDescription()}`).join(", ")} })`,h(o,"_parse",(i,f,c)=>{let t=i(f,c),{abortEarly:r}=y(c);if(t.success===false)return t;let a={},n=[];for(let u in e){let p=e[u]._parse(t.data[u],c);if(p.success)a[u]=p.data;else {if(p=p,r!==false){let m=d(p.error,u);return {success:false,error:m,errors:[m]}}b(p,n,u);}}return n.length>0?{success:false,error:n[0],errors:n}:{success:true,data:a}}),o},string(e){return l(x,{...e,type:"string"})},number(e){return l(k,{...e,type:"number"})},boolean(e){return l(w,{...e,type:"boolean"})},date(e){return l(E,{...e,type:"date"})},enum(e,s){let o=t=>e.includes(t),i=t=>`Invalid ${f} value. Expected ${e.map(r=>`"${r}"`).join(" | ")}, received "${t}".`,f="enum",c=l(o,{message:i,...s,type:f});return c._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,c},array(e,s){let o=l(_,{...s,type:"array"});return o._getDescription=()=>`array(${e._getDescription()})`,h(o,"_parse",(i,f,c)=>{let t=i(f,c),{abortEarly:r}=y(c);if(t.success===false)return t;let a=[],n=[];for(let u=0;u<t.data.length;u++){let p=e._parse(t.data[u],c);if(p.success)a.push(p.data);else {if(p=p,r!==false){let m=d(p.error,u);return {success:false,error:m,errors:[m]}}b(p,n,u);}}return n.length>0?{success:false,error:n[0],errors:n}:{success:true,data:a}}),o},any(){return l(()=>true)},preprocess(e,s){return h(s,"_parse",(o,i)=>(i=e(i),o(i))),s},union(e,s){return l(c=>{for(let t=0;t<e.length;t++){let r=e[t]._parse(c);if(r.success)return r}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,r)=>` ${r+1}. ${t._getDescription()}`).join(",")} but received "${typeof c}" with value: ${g(c)?JSON.stringify(c):`"${c}"`}`,...s,type:"union"})}};function O(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function h(e,s,o){let i=e[s];e[s]=(...f)=>o(i,...f);}function l(e,{type:s="any",name:o,message:i}={}){i=i||O(s);let f={name:o,message:i,type:s},c={_getName(){return o},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(t,r){let a=e(t);if(a===true)return {success:true,data:t};if(typeof a=="object"&&a?.success===true)return a;let n={message:typeof i=="function"?i(t):i};return {success:false,error:n,errors:[n]}},parse(t,r){let a=c._parse(t,r);if(!a.success)throw a=a,new Error(a.error.message,{cause:a.error.cause});return a.data},safeParse(t,r){return c._parse(t,r)},transform(t){return h(this,"_parse",(r,a,n)=>{let u=r(a,n);return u.success&&(u.data=t(u.data)),u}),this},optional(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r===void 0&&(n.data=void 0,n.success=true),n}),this},nullable(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r===null&&(n.data=null,n.success=true),n}),this},nullish(){return h(this,"_parse",(t,r,a)=>{let n=t(r,a);return !n.success&&r==null&&(n.success=true,n.data=r),n}),this},default(t){return h(this,"_parse",(r,a,n)=>(a===void 0&&(a=t,a=typeof t=="function"?t():t),r(a,n))),this},pipe(t){return h(this,"_parse",(r,a,n)=>{let u=r(a,n);return u.success?t._parse(u.data,n):u}),this},refine(t,{message:r,type:a}={}){return a&&(r=r||O(a),s=a),h(this,"_parse",(n,u,p)=>{let m=n(u,p);y(p);if(!m.success)return m;let I=t(m.data);if(I===true||typeof I=="object"&&I?.success===true)return m;let T={message:typeof r=="function"?r(u):r};return {success:false,error:T,errors:[T]}}),this}};return S.length>0?S.reduce((t,r)=>r(t,e,f)??t,c):c}var S=[];function $(e){S.push(e);}export{R as a,h as b,$ as c};
import {c}from'./chunk-NCHMO7B3.mjs';c((a,o,m)=>{if(m?.type==="array"){let r=a;r.min=function(e,{message:t}={}){return this.refine(n=>n.length>=e,{message:t||`Array must contain at least ${e} items.`})},r.max=function(e,{message:t}={}){return this.refine(n=>n.length<=e,{message:t||`Array must contain at most ${e} items.`})},r.length=function(e,{message:t}={}){return this.refine(n=>n.length===e,{message:t||`Array must contain exactly ${e} items.`})},r.nonEmpty=function({message:e}={}){return this.refine(t=>t.length>0,{message:e||"Array must not be empty."})},r.unique=function({message:e}={}){return this.refine(t=>{let n=new Set;try{return t.every(c=>{let s=JSON.stringify(c);return n.has(s)?!1:(n.add(s),!0)})}catch{return new Set(t).size===t.length}},{message:e||"Array items must be unique."})},r.sort=function(){return this.transform(e=>[...e].sort())},r.reverse=function(){return this.transform(e=>[...e].reverse())};}return a});
import {c}from'./chunk-NCHMO7B3.mjs';c((i,c,m)=>{if(m?.type==="number"){let n=i;n.min=function(e,{message:t}={}){return this.refine(r=>r>=e,{message:t||`Number must be greater than or equal to ${e}.`})},n.max=function(e,{message:t}={}){return this.refine(r=>r<=e,{message:t||`Number must be less than or equal to ${e}.`})},n.positive=function({message:e}={}){return this.refine(t=>t>0,{message:e||"Number must be positive."})},n.negative=function({message:e}={}){return this.refine(t=>t<0,{message:e||"Number must be negative."})},n.int=function({message:e}={}){return this.refine(t=>Number.isInteger(t),{message:e||"Number must be an integer."})},n.float=function({message:e}={}){return this.refine(t=>Number.isFinite(t)&&!Number.isInteger(t),{message:e||"Number must be a floating point (non-integer)."})},n.multipleOf=function(e,{message:t}={}){return this.refine(r=>r%e===0,{message:t||`Number must be a multiple of ${e}.`})},n.finite=function({message:e}={}){return this.refine(t=>Number.isFinite(t),{message:e||"Number must be finite."})};}return i});