var e;(function(e){e["required"]="required";e["max"]="max";e["maxlength"]="maxlength";e["min"]="min";e["minlength"]="minlength";e["pattern"]="pattern"})(e||(e={}));const t={required:()=>"This entry is required",maxlength:e=>`Please enter a value that is ${e} characters or less`,minlength:e=>`Please enter a value that is ${e} characters or more`,pattern:()=>"Please enter a value in the correct format"};const r=(e,t)=>{const r={validate:a=>{const n=e.validate(a);const s=t.validate(a);if(!n)r.errorMessage=e.errorMessage;else if(!s)r.errorMessage=t.errorMessage;return n&&s}};return r};const a=t=>Object.values(e).filter((e=>t[e]!=null)).map((e=>({name:e,customErrorMessage:t[`${e}Message`],options:t[e]})));const n=()=>({validate:e=>true});const s=e=>(e||[]).map((e=>d(e))).reduce(r,n());const i=e=>{const t=a(e);return s(t)};const o=e=>({errorMessage:e||t.required(),validate:e=>e&&"validity"in e?!e.validity.valueMissing:true});const c=(e,r)=>({errorMessage:e||t.maxlength(r),validate:e=>e&&"validity"in e?!e.validity.tooLong:true});const l=(e,r)=>({errorMessage:e||t.minlength(r),validate:e=>e&&"validity"in e?!e.validity.tooShort:true});const u=e=>({errorMessage:e||t.pattern(),validate:e=>e&&"validity"in e?!e.validity.patternMismatch:true});const d=t=>{const{name:r,customErrorMessage:a,options:s}=t;const{maxlength:i,minlength:d,pattern:m,required:v}=e;switch(r){case i:return c(a,s);case d:return l(a,s);case m:return u(a);case v:return o(a);default:return n()}};export{n as d,i};
//# sourceMappingURL=p-6b6961c0.js.map