Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zod-form-data

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zod-form-data - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

stats.html

1

browser/helpers.d.ts

@@ -60,2 +60,3 @@ import { z, ZodArray, ZodEffects, ZodNumber, ZodObject, ZodString, ZodTypeAny } from "zod";

export declare const json: <T extends z.ZodTypeAny>(schema: T) => z.ZodEffects<T, T["_output"], T["_input"]>;
export declare const preprocessFormData: (formData: unknown) => Record<string, unknown>;
/**

@@ -62,0 +63,0 @@ * This helper takes the place of the `z.object` at the root of your schema.

24

browser/helpers.js

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

import set from "lodash/set";
import { setPath } from "setGet";
import { z, ZodType, } from "zod";

@@ -86,10 +86,3 @@ const stripEmpty = z.literal("").transform(() => undefined);

export const json = (schema) => z.preprocess(preprocessIfValid(z.union([stripEmpty, z.string().transform((val) => safeParseJson(val))])), schema);
/**
* This helper takes the place of the `z.object` at the root of your schema.
* It wraps your schema in a `z.preprocess` that extracts all the data out of a `FormData`
* and transforms it into a regular object.
* If the `FormData` contains multiple entries with the same field name,
* it will automatically turn that field into an array.
*/
export const formData = (shapeOrSchema) => z.preprocess(preprocessIfValid(
const processFormData = preprocessIfValid(
// We're avoiding using `instanceof` here because different environments

@@ -113,4 +106,13 @@ // won't necessarily have `FormData` or `URLSearchParams`

return [...map.entries()].reduce((acc, [key, value]) => {
return set(acc, key, value.length === 1 ? value[0] : value);
return setPath(acc, key, value.length === 1 ? value[0] : value);
}, {});
})), shapeOrSchema instanceof ZodType ? shapeOrSchema : z.object(shapeOrSchema));
}));
export const preprocessFormData = processFormData;
/**
* This helper takes the place of the `z.object` at the root of your schema.
* It wraps your schema in a `z.preprocess` that extracts all the data out of a `FormData`
* and transforms it into a regular object.
* If the `FormData` contains multiple entries with the same field name,
* it will automatically turn that field into an array.
*/
export const formData = (shapeOrSchema) => z.preprocess(processFormData, shapeOrSchema instanceof ZodType ? shapeOrSchema : z.object(shapeOrSchema));

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

"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var n=require("zod"),_=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},te=typeof _=="object"&&_&&_.Object===Object&&_,ae=te,ne=ae,oe=typeof self=="object"&&self&&self.Object===Object&&self,se=ne||oe||Function("return this")(),C=se,ie=C,ce=ie.Symbol,S=ce,D=S,V=Object.prototype,ue=V.hasOwnProperty,fe=V.toString,l=D?D.toStringTag:void 0;function pe(e){var r=ue.call(e,l),t=e[l];try{e[l]=void 0;var a=!0}catch{}var o=fe.call(e);return a&&(r?e[l]=t:delete e[l]),o}var le=pe,he=Object.prototype,ve=he.toString;function _e(e){return ve.call(e)}var de=_e,M=S,ge=le,ye=de,be="[object Null]",$e="[object Undefined]",N=M?M.toStringTag:void 0;function me(e){return e==null?e===void 0?$e:be:N&&N in Object(e)?ge(e):ye(e)}var q=me;function Ce(e){var r=typeof e;return e!=null&&(r=="object"||r=="function")}var O=Ce,Se=q,Oe=O,ze="[object AsyncFunction]",Te="[object Function]",Pe="[object GeneratorFunction]",je="[object Proxy]";function Ie(e){if(!Oe(e))return!1;var r=Se(e);return r==Te||r==Pe||r==ze||r==je}var we=Ie,xe=C,De=xe["__core-js_shared__"],Me=De,m=Me,A=function(){var e=/[^.]+$/.exec(m&&m.keys&&m.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Ne(e){return!!A&&A in e}var Ae=Ne,Fe=Function.prototype,Ee=Fe.toString;function Ge(e){if(e!=null){try{return Ee.call(e)}catch{}try{return e+""}catch{}}return""}var He=Ge,Ke=we,Re=Ae,Le=O,Ve=He,qe=/[\\^$.*+?()[\]{}|]/g,Je=/^\[object .+?Constructor\]$/,Ue=Function.prototype,Xe=Object.prototype,Ze=Ue.toString,Ye=Xe.hasOwnProperty,Be=RegExp("^"+Ze.call(Ye).replace(qe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function Qe(e){if(!Le(e)||Re(e))return!1;var r=Ke(e)?Be:Je;return r.test(Ve(e))}var We=Qe;function ke(e,r){return e==null?void 0:e[r]}var er=ke,rr=We,tr=er;function ar(e,r){var t=tr(e,r);return rr(t)?t:void 0}var z=ar,nr=z,or=function(){try{var e=nr(Object,"defineProperty");return e({},"",{}),e}catch{}}(),sr=or,F=sr;function ir(e,r,t){r=="__proto__"&&F?F(e,r,{configurable:!0,enumerable:!0,value:t,writable:!0}):e[r]=t}var cr=ir;function ur(e,r){return e===r||e!==e&&r!==r}var J=ur,fr=cr,pr=J,lr=Object.prototype,hr=lr.hasOwnProperty;function vr(e,r,t){var a=e[r];(!(hr.call(e,r)&&pr(a,t))||t===void 0&&!(r in e))&&fr(e,r,t)}var _r=vr,dr=Array.isArray,T=dr;function gr(e){return e!=null&&typeof e=="object"}var yr=gr,br=q,$r=yr,mr="[object Symbol]";function Cr(e){return typeof e=="symbol"||$r(e)&&br(e)==mr}var P=Cr,Sr=T,Or=P,zr=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Tr=/^\w*$/;function Pr(e,r){if(Sr(e))return!1;var t=typeof e;return t=="number"||t=="symbol"||t=="boolean"||e==null||Or(e)?!0:Tr.test(e)||!zr.test(e)||r!=null&&e in Object(r)}var jr=Pr,Ir=z,wr=Ir(Object,"create"),d=wr,E=d;function xr(){this.__data__=E?E(null):{},this.size=0}var Dr=xr;function Mr(e){var r=this.has(e)&&delete this.__data__[e];return this.size-=r?1:0,r}var Nr=Mr,Ar=d,Fr="__lodash_hash_undefined__",Er=Object.prototype,Gr=Er.hasOwnProperty;function Hr(e){var r=this.__data__;if(Ar){var t=r[e];return t===Fr?void 0:t}return Gr.call(r,e)?r[e]:void 0}var Kr=Hr,Rr=d,Lr=Object.prototype,Vr=Lr.hasOwnProperty;function qr(e){var r=this.__data__;return Rr?r[e]!==void 0:Vr.call(r,e)}var Jr=qr,Ur=d,Xr="__lodash_hash_undefined__";function Zr(e,r){var t=this.__data__;return this.size+=this.has(e)?0:1,t[e]=Ur&&r===void 0?Xr:r,this}var Yr=Zr,Br=Dr,Qr=Nr,Wr=Kr,kr=Jr,et=Yr;function u(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var a=e[r];this.set(a[0],a[1])}}u.prototype.clear=Br;u.prototype.delete=Qr;u.prototype.get=Wr;u.prototype.has=kr;u.prototype.set=et;var rt=u;function tt(){this.__data__=[],this.size=0}var at=tt,nt=J;function ot(e,r){for(var t=e.length;t--;)if(nt(e[t][0],r))return t;return-1}var g=ot,st=g,it=Array.prototype,ct=it.splice;function ut(e){var r=this.__data__,t=st(r,e);if(t<0)return!1;var a=r.length-1;return t==a?r.pop():ct.call(r,t,1),--this.size,!0}var ft=ut,pt=g;function lt(e){var r=this.__data__,t=pt(r,e);return t<0?void 0:r[t][1]}var ht=lt,vt=g;function _t(e){return vt(this.__data__,e)>-1}var dt=_t,gt=g;function yt(e,r){var t=this.__data__,a=gt(t,e);return a<0?(++this.size,t.push([e,r])):t[a][1]=r,this}var bt=yt,$t=at,mt=ft,Ct=ht,St=dt,Ot=bt;function f(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var a=e[r];this.set(a[0],a[1])}}f.prototype.clear=$t;f.prototype.delete=mt;f.prototype.get=Ct;f.prototype.has=St;f.prototype.set=Ot;var zt=f,Tt=z,Pt=C,jt=Tt(Pt,"Map"),It=jt,G=rt,wt=zt,xt=It;function Dt(){this.size=0,this.__data__={hash:new G,map:new(xt||wt),string:new G}}var Mt=Dt;function Nt(e){var r=typeof e;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?e!=="__proto__":e===null}var At=Nt,Ft=At;function Et(e,r){var t=e.__data__;return Ft(r)?t[typeof r=="string"?"string":"hash"]:t.map}var y=Et,Gt=y;function Ht(e){var r=Gt(this,e).delete(e);return this.size-=r?1:0,r}var Kt=Ht,Rt=y;function Lt(e){return Rt(this,e).get(e)}var Vt=Lt,qt=y;function Jt(e){return qt(this,e).has(e)}var Ut=Jt,Xt=y;function Zt(e,r){var t=Xt(this,e),a=t.size;return t.set(e,r),this.size+=t.size==a?0:1,this}var Yt=Zt,Bt=Mt,Qt=Kt,Wt=Vt,kt=Ut,ea=Yt;function p(e){var r=-1,t=e==null?0:e.length;for(this.clear();++r<t;){var a=e[r];this.set(a[0],a[1])}}p.prototype.clear=Bt;p.prototype.delete=Qt;p.prototype.get=Wt;p.prototype.has=kt;p.prototype.set=ea;var ra=p,U=ra,ta="Expected a function";function j(e,r){if(typeof e!="function"||r!=null&&typeof r!="function")throw new TypeError(ta);var t=function(){var a=arguments,o=r?r.apply(this,a):a[0],s=t.cache;if(s.has(o))return s.get(o);var h=e.apply(this,a);return t.cache=s.set(o,h)||s,h};return t.cache=new(j.Cache||U),t}j.Cache=U;var aa=j,na=aa,oa=500;function sa(e){var r=na(e,function(a){return t.size===oa&&t.clear(),a}),t=r.cache;return r}var ia=sa,ca=ia,ua=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fa=/\\(\\)?/g,pa=ca(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(""),e.replace(ua,function(t,a,o,s){r.push(o?s.replace(fa,"$1"):a||t)}),r}),la=pa;function ha(e,r){for(var t=-1,a=e==null?0:e.length,o=Array(a);++t<a;)o[t]=r(e[t],t,e);return o}var va=ha,H=S,_a=va,da=T,ga=P,ya=1/0,K=H?H.prototype:void 0,R=K?K.toString:void 0;function X(e){if(typeof e=="string")return e;if(da(e))return _a(e,X)+"";if(ga(e))return R?R.call(e):"";var r=e+"";return r=="0"&&1/e==-ya?"-0":r}var ba=X,$a=ba;function ma(e){return e==null?"":$a(e)}var Ca=ma,Sa=T,Oa=jr,za=la,Ta=Ca;function Pa(e,r){return Sa(e)?e:Oa(e,r)?[e]:za(Ta(e))}var ja=Pa,Ia=9007199254740991,wa=/^(?:0|[1-9]\d*)$/;function xa(e,r){var t=typeof e;return r=r==null?Ia:r,!!r&&(t=="number"||t!="symbol"&&wa.test(e))&&e>-1&&e%1==0&&e<r}var Da=xa,Ma=P,Na=1/0;function Aa(e){if(typeof e=="string"||Ma(e))return e;var r=e+"";return r=="0"&&1/e==-Na?"-0":r}var Fa=Aa,Ea=_r,Ga=ja,Ha=Da,L=O,Ka=Fa;function Ra(e,r,t,a){if(!L(e))return e;r=Ga(r,e);for(var o=-1,s=r.length,h=s-1,c=e;c!=null&&++o<s;){var i=Ka(r[o]),v=t;if(i==="__proto__"||i==="constructor"||i==="prototype")return e;if(o!=h){var $=c[i];v=a?a($,i,c):void 0,v===void 0&&(v=L($)?$:Ha(r[o+1])?[]:{})}Ea(c,i,v),c=c[i]}return e}var La=Ra,Va=La;function qa(e,r,t){return e==null?e:Va(e,r,t)}var Ja=qa;const I=n.z.literal("").transform(()=>{}),b=e=>r=>{const t=e.safeParse(r);return t.success?t.data:r},w=(e=n.z.string())=>n.z.preprocess(b(I),e),Z=(e=n.z.number())=>n.z.preprocess(b(n.z.union([I,n.z.string().transform(r=>Number(r)).refine(r=>!Number.isNaN(r))])),e),Y=({trueValue:e="on"}={})=>n.z.union([n.z.literal(e).transform(()=>!0),n.z.literal(void 0).transform(()=>!1)]),B=(e=n.z.instanceof(File))=>n.z.preprocess(r=>r instanceof File&&r.size===0?void 0:r,e),x=(e=n.z.array(w()))=>n.z.preprocess(r=>Array.isArray(r)?r:r===void 0?[]:[r],e),Q=e=>x(n.z.array(e)),Ua=n.z.array(n.z.tuple([n.z.string(),n.z.any()])),Xa=e=>{try{return JSON.parse(e)}catch{return e}},W=e=>n.z.preprocess(b(n.z.union([I,n.z.string().transform(r=>Xa(r))])),e),k=b(n.z.any().refine(e=>Symbol.iterator in e).transform(e=>[...e]).refine(e=>Ua.safeParse(e).success).transform(e=>{const r=new Map;for(const[t,a]of e)r.has(t)?r.get(t).push(a):r.set(t,[a]);return[...r.entries()].reduce((t,[a,o])=>Ja(t,a,o.length===1?o[0]:o),{})})),ee=k,re=e=>n.z.preprocess(k,e instanceof n.ZodType?e:n.z.object(e));var Za=Object.freeze(Object.defineProperty({__proto__:null,text:w,numeric:Z,checkbox:Y,file:B,repeatable:x,repeatableOfType:Q,json:W,preprocessFormData:ee,formData:re},Symbol.toStringTag,{value:"Module"}));exports.checkbox=Y;exports.file=B;exports.formData=re;exports.json=W;exports.numeric=Z;exports.preprocessFormData=ee;exports.repeatable=x;exports.repeatableOfType=Q;exports.text=w;exports.zfd=Za;
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var t=require("zod");const z=e=>{if(e.length===0)return[];const r=e.match(/^\[(.+?)\](.*)$/)||e.match(/^\.?([^\.\[\]]+)(.*)$/);if(r){const[n,s,o]=r;return[/^\d+$/.test(s)?Number(s):s,...z(o)]}return[e]};function N(e,r,n){return T(e,z(r),n)}function T(e,r,n){var m;const s=r.slice(0,-1),o=r[r.length-1];let a=e;for(let c=0;c<s.length;c++){const u=s[c];if(a[u]===void 0){const D=(m=s[c+1])!=null?m:o;a[u]=typeof D=="number"?[]:{}}a=a[u]}return a[o]=n,e}const f=t.z.literal("").transform(()=>{}),i=e=>r=>{const n=e.safeParse(r);return n.success?n.data:r},l=(e=t.z.string())=>t.z.preprocess(i(f),e),b=(e=t.z.number())=>t.z.preprocess(i(t.z.union([f,t.z.string().transform(r=>Number(r)).refine(r=>!Number.isNaN(r))])),e),y=({trueValue:e="on"}={})=>t.z.union([t.z.literal(e).transform(()=>!0),t.z.literal(void 0).transform(()=>!1)]),d=(e=t.z.instanceof(File))=>t.z.preprocess(r=>r instanceof File&&r.size===0?void 0:r,e),p=(e=t.z.array(l()))=>t.z.preprocess(r=>Array.isArray(r)?r:r===void 0?[]:[r],e),g=e=>p(t.z.array(e)),j=t.z.array(t.z.tuple([t.z.string(),t.z.any()])),F=e=>{try{return JSON.parse(e)}catch{return e}},h=e=>t.z.preprocess(i(t.z.union([f,t.z.string().transform(r=>F(r))])),e),P=i(t.z.any().refine(e=>Symbol.iterator in e).transform(e=>[...e]).refine(e=>j.safeParse(e).success).transform(e=>{const r=new Map;for(const[n,s]of e)r.has(n)?r.get(n).push(s):r.set(n,[s]);return[...r.entries()].reduce((n,[s,o])=>N(n,s,o.length===1?o[0]:o),{})})),_=P,x=e=>t.z.preprocess(P,e instanceof t.ZodType?e:t.z.object(e));var S=Object.freeze(Object.defineProperty({__proto__:null,text:l,numeric:b,checkbox:y,file:d,repeatable:p,repeatableOfType:g,json:h,preprocessFormData:_,formData:x},Symbol.toStringTag,{value:"Module"}));exports.checkbox=y;exports.file=d;exports.formData=x;exports.json=h;exports.numeric=b;exports.preprocessFormData=_;exports.repeatable=p;exports.repeatableOfType=g;exports.text=l;exports.zfd=S;
//# sourceMappingURL=zod-form-data.cjs.js.map
import { z, ZodType } from "zod";
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
var _freeGlobal = freeGlobal$1;
var freeGlobal = _freeGlobal;
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
var root$3 = freeGlobal || freeSelf || Function("return this")();
var _root = root$3;
var root$2 = _root;
var Symbol$4 = root$2.Symbol;
var _Symbol = Symbol$4;
var Symbol$3 = _Symbol;
var objectProto$5 = Object.prototype;
var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
var nativeObjectToString$1 = objectProto$5.toString;
var symToStringTag$1 = Symbol$3 ? Symbol$3.toStringTag : void 0;
function getRawTag$1(value) {
var isOwn = hasOwnProperty$4.call(value, symToStringTag$1), tag = value[symToStringTag$1];
try {
value[symToStringTag$1] = void 0;
var unmasked = true;
} catch (e) {
const stringToPathArray = (path) => {
if (path.length === 0)
return [];
const match = path.match(/^\[(.+?)\](.*)$/) || path.match(/^\.?([^\.\[\]]+)(.*)$/);
if (match) {
const [_, key, rest] = match;
return [/^\d+$/.test(key) ? Number(key) : key, ...stringToPathArray(rest)];
}
var result = nativeObjectToString$1.call(value);
if (unmasked) {
if (isOwn) {
value[symToStringTag$1] = tag;
} else {
delete value[symToStringTag$1];
}
}
return result;
return [path];
};
function setPath(object, path, defaultValue) {
return _setPathNormalized(object, stringToPathArray(path), defaultValue);
}
var _getRawTag = getRawTag$1;
var objectProto$4 = Object.prototype;
var nativeObjectToString = objectProto$4.toString;
function objectToString$1(value) {
return nativeObjectToString.call(value);
}
var _objectToString = objectToString$1;
var Symbol$2 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : void 0;
function baseGetTag$2(value) {
if (value == null) {
return value === void 0 ? undefinedTag : nullTag;
}
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
}
var _baseGetTag = baseGetTag$2;
function isObject$3(value) {
var type = typeof value;
return value != null && (type == "object" || type == "function");
}
var isObject_1 = isObject$3;
var baseGetTag$1 = _baseGetTag, isObject$2 = isObject_1;
var asyncTag = "[object AsyncFunction]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
function isFunction$1(value) {
if (!isObject$2(value)) {
return false;
}
var tag = baseGetTag$1(value);
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
}
var isFunction_1 = isFunction$1;
var root$1 = _root;
var coreJsData$1 = root$1["__core-js_shared__"];
var _coreJsData = coreJsData$1;
var coreJsData = _coreJsData;
var maskSrcKey = function() {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
return uid ? "Symbol(src)_1." + uid : "";
}();
function isMasked$1(func) {
return !!maskSrcKey && maskSrcKey in func;
}
var _isMasked = isMasked$1;
var funcProto$1 = Function.prototype;
var funcToString$1 = funcProto$1.toString;
function toSource$1(func) {
if (func != null) {
try {
return funcToString$1.call(func);
} catch (e) {
function _setPathNormalized(object, path, value) {
var _a;
const leadingSegments = path.slice(0, -1);
const lastSegment = path[path.length - 1];
let obj = object;
for (let i = 0; i < leadingSegments.length; i++) {
const segment = leadingSegments[i];
if (obj[segment] === void 0) {
const nextSegment = (_a = leadingSegments[i + 1]) != null ? _a : lastSegment;
obj[segment] = typeof nextSegment === "number" ? [] : {};
}
try {
return func + "";
} catch (e) {
}
obj = obj[segment];
}
return "";
}
var _toSource = toSource$1;
var isFunction = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource = _toSource;
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
var reIsHostCtor = /^\[object .+?Constructor\]$/;
var funcProto = Function.prototype, objectProto$3 = Object.prototype;
var funcToString = funcProto.toString;
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
var reIsNative = RegExp(
"^" + funcToString.call(hasOwnProperty$3).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
);
function baseIsNative$1(value) {
if (!isObject$1(value) || isMasked(value)) {
return false;
}
var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
return pattern.test(toSource(value));
}
var _baseIsNative = baseIsNative$1;
function getValue$1(object, key) {
return object == null ? void 0 : object[key];
}
var _getValue = getValue$1;
var baseIsNative = _baseIsNative, getValue = _getValue;
function getNative$3(object, key) {
var value = getValue(object, key);
return baseIsNative(value) ? value : void 0;
}
var _getNative = getNative$3;
var getNative$2 = _getNative;
var defineProperty$1 = function() {
try {
var func = getNative$2(Object, "defineProperty");
func({}, "", {});
return func;
} catch (e) {
}
}();
var _defineProperty = defineProperty$1;
var defineProperty = _defineProperty;
function baseAssignValue$1(object, key, value) {
if (key == "__proto__" && defineProperty) {
defineProperty(object, key, {
"configurable": true,
"enumerable": true,
"value": value,
"writable": true
});
} else {
object[key] = value;
}
}
var _baseAssignValue = baseAssignValue$1;
function eq$2(value, other) {
return value === other || value !== value && other !== other;
}
var eq_1 = eq$2;
var baseAssignValue = _baseAssignValue, eq$1 = eq_1;
var objectProto$2 = Object.prototype;
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
function assignValue$1(object, key, value) {
var objValue = object[key];
if (!(hasOwnProperty$2.call(object, key) && eq$1(objValue, value)) || value === void 0 && !(key in object)) {
baseAssignValue(object, key, value);
}
}
var _assignValue = assignValue$1;
var isArray$3 = Array.isArray;
var isArray_1 = isArray$3;
function isObjectLike$1(value) {
return value != null && typeof value == "object";
}
var isObjectLike_1 = isObjectLike$1;
var baseGetTag = _baseGetTag, isObjectLike = isObjectLike_1;
var symbolTag = "[object Symbol]";
function isSymbol$3(value) {
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
}
var isSymbol_1 = isSymbol$3;
var isArray$2 = isArray_1, isSymbol$2 = isSymbol_1;
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
function isKey$1(value, object) {
if (isArray$2(value)) {
return false;
}
var type = typeof value;
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
return true;
}
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
}
var _isKey = isKey$1;
var getNative$1 = _getNative;
var nativeCreate$4 = getNative$1(Object, "create");
var _nativeCreate = nativeCreate$4;
var nativeCreate$3 = _nativeCreate;
function hashClear$1() {
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
this.size = 0;
}
var _hashClear = hashClear$1;
function hashDelete$1(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
var _hashDelete = hashDelete$1;
var nativeCreate$2 = _nativeCreate;
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
var objectProto$1 = Object.prototype;
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
function hashGet$1(key) {
var data = this.__data__;
if (nativeCreate$2) {
var result = data[key];
return result === HASH_UNDEFINED$1 ? void 0 : result;
}
return hasOwnProperty$1.call(data, key) ? data[key] : void 0;
}
var _hashGet = hashGet$1;
var nativeCreate$1 = _nativeCreate;
var objectProto = Object.prototype;
var hasOwnProperty = objectProto.hasOwnProperty;
function hashHas$1(key) {
var data = this.__data__;
return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty.call(data, key);
}
var _hashHas = hashHas$1;
var nativeCreate = _nativeCreate;
var HASH_UNDEFINED = "__lodash_hash_undefined__";
function hashSet$1(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
return this;
}
var _hashSet = hashSet$1;
var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
function Hash$1(entries2) {
var index = -1, length = entries2 == null ? 0 : entries2.length;
this.clear();
while (++index < length) {
var entry = entries2[index];
this.set(entry[0], entry[1]);
}
}
Hash$1.prototype.clear = hashClear;
Hash$1.prototype["delete"] = hashDelete;
Hash$1.prototype.get = hashGet;
Hash$1.prototype.has = hashHas;
Hash$1.prototype.set = hashSet;
var _Hash = Hash$1;
function listCacheClear$1() {
this.__data__ = [];
this.size = 0;
}
var _listCacheClear = listCacheClear$1;
var eq = eq_1;
function assocIndexOf$4(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
var _assocIndexOf = assocIndexOf$4;
var assocIndexOf$3 = _assocIndexOf;
var arrayProto = Array.prototype;
var splice = arrayProto.splice;
function listCacheDelete$1(key) {
var data = this.__data__, index = assocIndexOf$3(data, key);
if (index < 0) {
return false;
}
var lastIndex = data.length - 1;
if (index == lastIndex) {
data.pop();
} else {
splice.call(data, index, 1);
}
--this.size;
return true;
}
var _listCacheDelete = listCacheDelete$1;
var assocIndexOf$2 = _assocIndexOf;
function listCacheGet$1(key) {
var data = this.__data__, index = assocIndexOf$2(data, key);
return index < 0 ? void 0 : data[index][1];
}
var _listCacheGet = listCacheGet$1;
var assocIndexOf$1 = _assocIndexOf;
function listCacheHas$1(key) {
return assocIndexOf$1(this.__data__, key) > -1;
}
var _listCacheHas = listCacheHas$1;
var assocIndexOf = _assocIndexOf;
function listCacheSet$1(key, value) {
var data = this.__data__, index = assocIndexOf(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
var _listCacheSet = listCacheSet$1;
var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
function ListCache$1(entries2) {
var index = -1, length = entries2 == null ? 0 : entries2.length;
this.clear();
while (++index < length) {
var entry = entries2[index];
this.set(entry[0], entry[1]);
}
}
ListCache$1.prototype.clear = listCacheClear;
ListCache$1.prototype["delete"] = listCacheDelete;
ListCache$1.prototype.get = listCacheGet;
ListCache$1.prototype.has = listCacheHas;
ListCache$1.prototype.set = listCacheSet;
var _ListCache = ListCache$1;
var getNative = _getNative, root = _root;
var Map$2 = getNative(root, "Map");
var _Map = Map$2;
var Hash = _Hash, ListCache = _ListCache, Map$1 = _Map;
function mapCacheClear$1() {
this.size = 0;
this.__data__ = {
"hash": new Hash(),
"map": new (Map$1 || ListCache)(),
"string": new Hash()
};
}
var _mapCacheClear = mapCacheClear$1;
function isKeyable$1(value) {
var type = typeof value;
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
}
var _isKeyable = isKeyable$1;
var isKeyable = _isKeyable;
function getMapData$4(map, key) {
var data = map.__data__;
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
}
var _getMapData = getMapData$4;
var getMapData$3 = _getMapData;
function mapCacheDelete$1(key) {
var result = getMapData$3(this, key)["delete"](key);
this.size -= result ? 1 : 0;
return result;
}
var _mapCacheDelete = mapCacheDelete$1;
var getMapData$2 = _getMapData;
function mapCacheGet$1(key) {
return getMapData$2(this, key).get(key);
}
var _mapCacheGet = mapCacheGet$1;
var getMapData$1 = _getMapData;
function mapCacheHas$1(key) {
return getMapData$1(this, key).has(key);
}
var _mapCacheHas = mapCacheHas$1;
var getMapData = _getMapData;
function mapCacheSet$1(key, value) {
var data = getMapData(this, key), size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
var _mapCacheSet = mapCacheSet$1;
var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
function MapCache$1(entries2) {
var index = -1, length = entries2 == null ? 0 : entries2.length;
this.clear();
while (++index < length) {
var entry = entries2[index];
this.set(entry[0], entry[1]);
}
}
MapCache$1.prototype.clear = mapCacheClear;
MapCache$1.prototype["delete"] = mapCacheDelete;
MapCache$1.prototype.get = mapCacheGet;
MapCache$1.prototype.has = mapCacheHas;
MapCache$1.prototype.set = mapCacheSet;
var _MapCache = MapCache$1;
var MapCache = _MapCache;
var FUNC_ERROR_TEXT = "Expected a function";
function memoize$1(func, resolver) {
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize$1.Cache || MapCache)();
return memoized;
}
memoize$1.Cache = MapCache;
var memoize_1 = memoize$1;
var memoize = memoize_1;
var MAX_MEMOIZE_SIZE = 500;
function memoizeCapped$1(func) {
var result = memoize(func, function(key) {
if (cache.size === MAX_MEMOIZE_SIZE) {
cache.clear();
}
return key;
});
var cache = result.cache;
return result;
}
var _memoizeCapped = memoizeCapped$1;
var memoizeCapped = _memoizeCapped;
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
var reEscapeChar = /\\(\\)?/g;
var stringToPath$1 = memoizeCapped(function(string) {
var result = [];
if (string.charCodeAt(0) === 46) {
result.push("");
}
string.replace(rePropName, function(match, number, quote, subString) {
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
});
return result;
});
var _stringToPath = stringToPath$1;
function arrayMap$1(array, iteratee) {
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
var _arrayMap = arrayMap$1;
var Symbol$1 = _Symbol, arrayMap = _arrayMap, isArray$1 = isArray_1, isSymbol$1 = isSymbol_1;
var INFINITY$1 = 1 / 0;
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
function baseToString$1(value) {
if (typeof value == "string") {
return value;
}
if (isArray$1(value)) {
return arrayMap(value, baseToString$1) + "";
}
if (isSymbol$1(value)) {
return symbolToString ? symbolToString.call(value) : "";
}
var result = value + "";
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
}
var _baseToString = baseToString$1;
var baseToString = _baseToString;
function toString$1(value) {
return value == null ? "" : baseToString(value);
}
var toString_1 = toString$1;
var isArray = isArray_1, isKey = _isKey, stringToPath = _stringToPath, toString = toString_1;
function castPath$1(value, object) {
if (isArray(value)) {
return value;
}
return isKey(value, object) ? [value] : stringToPath(toString(value));
}
var _castPath = castPath$1;
var MAX_SAFE_INTEGER = 9007199254740991;
var reIsUint = /^(?:0|[1-9]\d*)$/;
function isIndex$1(value, length) {
var type = typeof value;
length = length == null ? MAX_SAFE_INTEGER : length;
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
}
var _isIndex = isIndex$1;
var isSymbol = isSymbol_1;
var INFINITY = 1 / 0;
function toKey$1(value) {
if (typeof value == "string" || isSymbol(value)) {
return value;
}
var result = value + "";
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
}
var _toKey = toKey$1;
var assignValue = _assignValue, castPath = _castPath, isIndex = _isIndex, isObject = isObject_1, toKey = _toKey;
function baseSet$1(object, path, value, customizer) {
if (!isObject(object)) {
return object;
}
path = castPath(path, object);
var index = -1, length = path.length, lastIndex = length - 1, nested = object;
while (nested != null && ++index < length) {
var key = toKey(path[index]), newValue = value;
if (key === "__proto__" || key === "constructor" || key === "prototype") {
return object;
}
if (index != lastIndex) {
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : void 0;
if (newValue === void 0) {
newValue = isObject(objValue) ? objValue : isIndex(path[index + 1]) ? [] : {};
}
}
assignValue(nested, key, newValue);
nested = nested[key];
}
obj[lastSegment] = value;
return object;
}
var _baseSet = baseSet$1;
var baseSet = _baseSet;
function set(object, path, value) {
return object == null ? object : baseSet(object, path, value);
}
var set_1 = set;
const stripEmpty = z.literal("").transform(() => void 0);

@@ -574,3 +92,3 @@ const preprocessIfValid = (schema) => (val) => {

return [...map.entries()].reduce((acc, [key, value]) => {
return set_1(acc, key, value.length === 1 ? value[0] : value);
return setPath(acc, key, value.length === 1 ? value[0] : value);
}, {});

@@ -577,0 +95,0 @@ })

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

(function(s,n){typeof exports=="object"&&typeof module!="undefined"?n(exports,require("zod")):typeof define=="function"&&define.amd?define(["exports","zod"],n):(s=typeof globalThis!="undefined"?globalThis:s||self,n(s["zod-form-data"]={},s.zod))})(this,function(s,n){"use strict";var v=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},ae=typeof v=="object"&&v&&v.Object===Object&&v,ne=ae,ie=ne,se=typeof self=="object"&&self&&self.Object===Object&&self,oe=ie||se||Function("return this")(),m=oe,ce=m,fe=ce.Symbol,C=fe,N=C,x=Object.prototype,ue=x.hasOwnProperty,pe=x.toString,h=N?N.toStringTag:void 0;function le(e){var t=ue.call(e,h),r=e[h];try{e[h]=void 0;var a=!0}catch{}var i=pe.call(e);return a&&(t?e[h]=r:delete e[h]),i}var he=le,ve=Object.prototype,_e=ve.toString;function de(e){return _e.call(e)}var ye=de,A=C,ge=he,be=ye,$e="[object Null]",me="[object Undefined]",F=A?A.toStringTag:void 0;function Ce(e){return e==null?e===void 0?me:$e:F&&F in Object(e)?ge(e):be(e)}var E=Ce;function Se(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var S=Se,Oe=E,Te=S,Pe="[object AsyncFunction]",je="[object Function]",Ie="[object GeneratorFunction]",we="[object Proxy]";function De(e){if(!Te(e))return!1;var t=Oe(e);return t==je||t==Ie||t==Pe||t==we}var Me=De,ze=m,Ne=ze["__core-js_shared__"],xe=Ne,O=xe,G=function(){var e=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function Ae(e){return!!G&&G in e}var Fe=Ae,Ee=Function.prototype,Ge=Ee.toString;function He(e){if(e!=null){try{return Ge.call(e)}catch{}try{return e+""}catch{}}return""}var Ke=He,Re=Me,Le=Fe,Ve=S,qe=Ke,Je=/[\\^$.*+?()[\]{}|]/g,Ue=/^\[object .+?Constructor\]$/,Xe=Function.prototype,Ze=Object.prototype,Ye=Xe.toString,Be=Ze.hasOwnProperty,Qe=RegExp("^"+Ye.call(Be).replace(Je,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function We(e){if(!Ve(e)||Le(e))return!1;var t=Re(e)?Qe:Ue;return t.test(qe(e))}var ke=We;function et(e,t){return e==null?void 0:e[t]}var tt=et,rt=ke,at=tt;function nt(e,t){var r=at(e,t);return rt(r)?r:void 0}var T=nt,it=T,st=function(){try{var e=it(Object,"defineProperty");return e({},"",{}),e}catch{}}(),ot=st,H=ot;function ct(e,t,r){t=="__proto__"&&H?H(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}var ft=ct;function ut(e,t){return e===t||e!==e&&t!==t}var K=ut,pt=ft,lt=K,ht=Object.prototype,vt=ht.hasOwnProperty;function _t(e,t,r){var a=e[t];(!(vt.call(e,t)&&lt(a,r))||r===void 0&&!(t in e))&&pt(e,t,r)}var dt=_t,yt=Array.isArray,P=yt;function gt(e){return e!=null&&typeof e=="object"}var bt=gt,$t=E,mt=bt,Ct="[object Symbol]";function St(e){return typeof e=="symbol"||mt(e)&&$t(e)==Ct}var j=St,Ot=P,Tt=j,Pt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jt=/^\w*$/;function It(e,t){if(Ot(e))return!1;var r=typeof e;return r=="number"||r=="symbol"||r=="boolean"||e==null||Tt(e)?!0:jt.test(e)||!Pt.test(e)||t!=null&&e in Object(t)}var wt=It,Dt=T,Mt=Dt(Object,"create"),_=Mt,R=_;function zt(){this.__data__=R?R(null):{},this.size=0}var Nt=zt;function xt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var At=xt,Ft=_,Et="__lodash_hash_undefined__",Gt=Object.prototype,Ht=Gt.hasOwnProperty;function Kt(e){var t=this.__data__;if(Ft){var r=t[e];return r===Et?void 0:r}return Ht.call(t,e)?t[e]:void 0}var Rt=Kt,Lt=_,Vt=Object.prototype,qt=Vt.hasOwnProperty;function Jt(e){var t=this.__data__;return Lt?t[e]!==void 0:qt.call(t,e)}var Ut=Jt,Xt=_,Zt="__lodash_hash_undefined__";function Yt(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Xt&&t===void 0?Zt:t,this}var Bt=Yt,Qt=Nt,Wt=At,kt=Rt,er=Ut,tr=Bt;function f(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}f.prototype.clear=Qt,f.prototype.delete=Wt,f.prototype.get=kt,f.prototype.has=er,f.prototype.set=tr;var rr=f;function ar(){this.__data__=[],this.size=0}var nr=ar,ir=K;function sr(e,t){for(var r=e.length;r--;)if(ir(e[r][0],t))return r;return-1}var d=sr,or=d,cr=Array.prototype,fr=cr.splice;function ur(e){var t=this.__data__,r=or(t,e);if(r<0)return!1;var a=t.length-1;return r==a?t.pop():fr.call(t,r,1),--this.size,!0}var pr=ur,lr=d;function hr(e){var t=this.__data__,r=lr(t,e);return r<0?void 0:t[r][1]}var vr=hr,_r=d;function dr(e){return _r(this.__data__,e)>-1}var yr=dr,gr=d;function br(e,t){var r=this.__data__,a=gr(r,e);return a<0?(++this.size,r.push([e,t])):r[a][1]=t,this}var $r=br,mr=nr,Cr=pr,Sr=vr,Or=yr,Tr=$r;function u(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}u.prototype.clear=mr,u.prototype.delete=Cr,u.prototype.get=Sr,u.prototype.has=Or,u.prototype.set=Tr;var Pr=u,jr=T,Ir=m,wr=jr(Ir,"Map"),Dr=wr,L=rr,Mr=Pr,zr=Dr;function Nr(){this.size=0,this.__data__={hash:new L,map:new(zr||Mr),string:new L}}var xr=Nr;function Ar(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var Fr=Ar,Er=Fr;function Gr(e,t){var r=e.__data__;return Er(t)?r[typeof t=="string"?"string":"hash"]:r.map}var y=Gr,Hr=y;function Kr(e){var t=Hr(this,e).delete(e);return this.size-=t?1:0,t}var Rr=Kr,Lr=y;function Vr(e){return Lr(this,e).get(e)}var qr=Vr,Jr=y;function Ur(e){return Jr(this,e).has(e)}var Xr=Ur,Zr=y;function Yr(e,t){var r=Zr(this,e),a=r.size;return r.set(e,t),this.size+=r.size==a?0:1,this}var Br=Yr,Qr=xr,Wr=Rr,kr=qr,ea=Xr,ta=Br;function p(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var a=e[t];this.set(a[0],a[1])}}p.prototype.clear=Qr,p.prototype.delete=Wr,p.prototype.get=kr,p.prototype.has=ea,p.prototype.set=ta;var ra=p,V=ra,aa="Expected a function";function I(e,t){if(typeof e!="function"||t!=null&&typeof t!="function")throw new TypeError(aa);var r=function(){var a=arguments,i=t?t.apply(this,a):a[0],o=r.cache;if(o.has(i))return o.get(i);var b=e.apply(this,a);return r.cache=o.set(i,b)||o,b};return r.cache=new(I.Cache||V),r}I.Cache=V;var na=I,ia=na,sa=500;function oa(e){var t=ia(e,function(a){return r.size===sa&&r.clear(),a}),r=t.cache;return t}var ca=oa,fa=ca,ua=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,pa=/\\(\\)?/g,la=fa(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(""),e.replace(ua,function(r,a,i,o){t.push(i?o.replace(pa,"$1"):a||r)}),t}),ha=la;function va(e,t){for(var r=-1,a=e==null?0:e.length,i=Array(a);++r<a;)i[r]=t(e[r],r,e);return i}var _a=va,q=C,da=_a,ya=P,ga=j,ba=1/0,J=q?q.prototype:void 0,U=J?J.toString:void 0;function X(e){if(typeof e=="string")return e;if(ya(e))return da(e,X)+"";if(ga(e))return U?U.call(e):"";var t=e+"";return t=="0"&&1/e==-ba?"-0":t}var $a=X,ma=$a;function Ca(e){return e==null?"":ma(e)}var Sa=Ca,Oa=P,Ta=wt,Pa=ha,ja=Sa;function Ia(e,t){return Oa(e)?e:Ta(e,t)?[e]:Pa(ja(e))}var wa=Ia,Da=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function za(e,t){var r=typeof e;return t=t==null?Da:t,!!t&&(r=="number"||r!="symbol"&&Ma.test(e))&&e>-1&&e%1==0&&e<t}var Na=za,xa=j,Aa=1/0;function Fa(e){if(typeof e=="string"||xa(e))return e;var t=e+"";return t=="0"&&1/e==-Aa?"-0":t}var Ea=Fa,Ga=dt,Ha=wa,Ka=Na,Z=S,Ra=Ea;function La(e,t,r,a){if(!Z(e))return e;t=Ha(t,e);for(var i=-1,o=t.length,b=o-1,l=e;l!=null&&++i<o;){var c=Ra(t[i]),$=r;if(c==="__proto__"||c==="constructor"||c==="prototype")return e;if(i!=b){var z=l[c];$=a?a(z,c,l):void 0,$===void 0&&($=Z(z)?z:Ka(t[i+1])?[]:{})}Ga(l,c,$),l=l[c]}return e}var Va=La,qa=Va;function Ja(e,t,r){return e==null?e:qa(e,t,r)}var Ua=Ja;const w=n.z.literal("").transform(()=>{}),g=e=>t=>{const r=e.safeParse(t);return r.success?r.data:t},D=(e=n.z.string())=>n.z.preprocess(g(w),e),Y=(e=n.z.number())=>n.z.preprocess(g(n.z.union([w,n.z.string().transform(t=>Number(t)).refine(t=>!Number.isNaN(t))])),e),B=({trueValue:e="on"}={})=>n.z.union([n.z.literal(e).transform(()=>!0),n.z.literal(void 0).transform(()=>!1)]),Q=(e=n.z.instanceof(File))=>n.z.preprocess(t=>t instanceof File&&t.size===0?void 0:t,e),M=(e=n.z.array(D()))=>n.z.preprocess(t=>Array.isArray(t)?t:t===void 0?[]:[t],e),W=e=>M(n.z.array(e)),Xa=n.z.array(n.z.tuple([n.z.string(),n.z.any()])),Za=e=>{try{return JSON.parse(e)}catch{return e}},k=e=>n.z.preprocess(g(n.z.union([w,n.z.string().transform(t=>Za(t))])),e),ee=g(n.z.any().refine(e=>Symbol.iterator in e).transform(e=>[...e]).refine(e=>Xa.safeParse(e).success).transform(e=>{const t=new Map;for(const[r,a]of e)t.has(r)?t.get(r).push(a):t.set(r,[a]);return[...t.entries()].reduce((r,[a,i])=>Ua(r,a,i.length===1?i[0]:i),{})})),te=ee,re=e=>n.z.preprocess(ee,e instanceof n.ZodType?e:n.z.object(e));var Ya=Object.freeze(Object.defineProperty({__proto__:null,text:D,numeric:Y,checkbox:B,file:Q,repeatable:M,repeatableOfType:W,json:k,preprocessFormData:te,formData:re},Symbol.toStringTag,{value:"Module"}));s.checkbox=B,s.file=Q,s.formData=re,s.json=k,s.numeric=Y,s.preprocessFormData=te,s.repeatable=M,s.repeatableOfType=W,s.text=D,s.zfd=Ya,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("zod")):typeof define=="function"&&define.amd?define(["exports","zod"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n["zod-form-data"]={},n.zod))})(this,function(n,t){"use strict";const y=e=>{if(e.length===0)return[];const r=e.match(/^\[(.+?)\](.*)$/)||e.match(/^\.?([^\.\[\]]+)(.*)$/);if(r){const[s,i,o]=r;return[/^\d+$/.test(i)?Number(i):i,...y(o)]}return[e]};function D(e,r,s){return N(e,y(r),s)}function N(e,r,s){var j;const i=r.slice(0,-1),o=r[r.length-1];let a=e;for(let f=0;f<i.length;f++){const p=i[f];if(a[p]===void 0){const O=(j=i[f+1])!=null?j:o;a[p]=typeof O=="number"?[]:{}}a=a[p]}return a[o]=s,e}const u=t.z.literal("").transform(()=>{}),c=e=>r=>{const s=e.safeParse(r);return s.success?s.data:r},l=(e=t.z.string())=>t.z.preprocess(c(u),e),b=(e=t.z.number())=>t.z.preprocess(c(t.z.union([u,t.z.string().transform(r=>Number(r)).refine(r=>!Number.isNaN(r))])),e),g=({trueValue:e="on"}={})=>t.z.union([t.z.literal(e).transform(()=>!0),t.z.literal(void 0).transform(()=>!1)]),h=(e=t.z.instanceof(File))=>t.z.preprocess(r=>r instanceof File&&r.size===0?void 0:r,e),m=(e=t.z.array(l()))=>t.z.preprocess(r=>Array.isArray(r)?r:r===void 0?[]:[r],e),T=e=>m(t.z.array(e)),F=t.z.array(t.z.tuple([t.z.string(),t.z.any()])),S=e=>{try{return JSON.parse(e)}catch{return e}},z=e=>t.z.preprocess(c(t.z.union([u,t.z.string().transform(r=>S(r))])),e),P=c(t.z.any().refine(e=>Symbol.iterator in e).transform(e=>[...e]).refine(e=>F.safeParse(e).success).transform(e=>{const r=new Map;for(const[s,i]of e)r.has(s)?r.get(s).push(i):r.set(s,[i]);return[...r.entries()].reduce((s,[i,o])=>D(s,i,o.length===1?o[0]:o),{})})),_=P,d=e=>t.z.preprocess(P,e instanceof t.ZodType?e:t.z.object(e));var k=Object.freeze(Object.defineProperty({__proto__:null,text:l,numeric:b,checkbox:g,file:h,repeatable:m,repeatableOfType:T,json:z,preprocessFormData:_,formData:d},Symbol.toStringTag,{value:"Module"}));n.checkbox=g,n.file=h,n.formData=d,n.json=z,n.numeric=b,n.preprocessFormData=_,n.repeatable=m,n.repeatableOfType=T,n.text=l,n.zfd=k,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
//# sourceMappingURL=zod-form-data.umd.js.map
{
"name": "zod-form-data",
"version": "1.2.2",
"version": "1.2.3",
"browser": "./dist/zod-form-data.cjs.js",

@@ -22,5 +22,5 @@ "main": "./dist/zod-form-data.umd.js",

"tsconfig": "*",
"typescript": "^4.5.4",
"typescript": "^4.8.4",
"zod": "^3.11.6"
}
}

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

import set from "lodash/set";
import { setPath } from "setGet";
import {

@@ -159,3 +159,3 @@ z,

return [...map.entries()].reduce((acc, [key, value]) => {
return set(acc, key, value.length === 1 ? value[0] : value);
return setPath(acc, key, value.length === 1 ? value[0] : value);
}, {} as Record<string, unknown | unknown[]>);

@@ -162,0 +162,0 @@ })

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc