class t{static VALID={valid:!0};static invalid(t){return{valid:!1,code:t}}}class n{validate(n,i){return this._isEmpty(n)?t.invalid("empty"):t.VALID}_isEmpty(t){return null==t||("string"==typeof t?0===t.length:"number"==typeof t?Number.isNaN(t):!!Array.isArray(t)&&0===t.length)}}class i{constructor({min:t,max:n}={}){this._min=t,this._max=n}validate(n,i){const a=this._parse(n);if(null==a||isNaN(a))return t.invalid("badType");const e=this._getRange();return null==e?t.VALID:a<e.min?t.invalid("rangeUnderflow"):a>e.max?t.invalid("rangeOverflow"):t.VALID}_parse(t){return"number"==typeof t?t:"string"==typeof t?Number(t):null}_getRange(){return null==this._min&&null==this._max?null:{min:this._min??-1/0,max:this._max??1/0}}}class a{validate(n,i){return n.match(/^\S+@\S+\.\S+$/gm)?t.VALID:t.invalid("badEmail")}}class e{validate(n,i){return t.VALID}}const r=new e;function l(n){const i=n.filter((t=>null!=t));return 0===i.length?r:1===i.length?i[0]:s(((n,a)=>{for(const t of i){const i=t.validate(n,a);if(!1===i.valid)return i}return t.VALID}))}function s(t){return{validate:t}}export{a as EmailValidator,i as NumberValidator,n as RequiredValidator,e as ValidValidator,t as Validation,l as combineValidators,s as createValidator};
//# sourceMappingURL=validation.js.map
