UNPKG

@atlas-kitchen/adyen-web

Version:
3 lines (2 loc) 849 B
import{isEmpty as e}from"../validator-utils.js";import{ERROR_FIELD_REQUIRED as r,ERROR_FIELD_INVALID as t}from"../../core/Errors/constants.js";import{email as s,telephoneNumber as o}from"../regex.js";import{unformatDate as a}from"../../components/internal/FormFields/InputDate/utils.js";const l={validate:s=>((s,a)=>e(s)?(a.errorMessage=r,null):(a.errorMessage=t,o.test(s)))(s,l),modes:["blur"]},n={validate:o=>((o,a)=>e(o)?(a.errorMessage=r,null):(a.errorMessage=t,o.length>=6&&o.length<=320&&s.test(o)))(o,n),modes:["blur"]},i={validate:e=>((e,t)=>{if(!e)return t.errorMessage=r,!1;t.errorMessage="dateOfBirth.invalid";const s=a(e),o=Date.now()-Date.parse(s);return new Date(o).getFullYear()-1970>=18})(e,i),modes:["blur"]},m={phoneNumberRule:l,emailRule:n,dateOfBirthRule:i};export{m as validationRules}; //# sourceMappingURL=defaultRules.js.map