UNPKG

@deposits/validators

Version:

A collection of Fintech-specific and general-purpose validators, designed to extend popular validation libraries like Vuelidate, Zod, and yup.

2 lines (1 loc) 1.72 kB
var t=function(t){return!((t=t.trim()).length<4||t.length>17)&&/^[0-9]+$/.test(t)},r=function(t){if(t=(t=t.trim()).replaceAll(" ",""),/^\d+$/.test(t)){for(var r=0,n=!1,e=t.length-1;e>=0;e--){var u=parseInt(t.charAt(e));n&&(u*=2)>9&&(u-=9),r+=u,n=!n}return r%10==0&&(!!/^3[47]\d{13}$/.test(t)||(!!/^4\d{12}(\d{3})?$/.test(t)||(!!/^5[1-5]\d{14}$/.test(t)||!!/^6(?:011|5\d{2})\d{12}$/.test(t))))}return!1},n=function(t){t=t.trim();return/^\d{2}-\d{7}$/.test(t)},e=function(t){if(t.length>63)return!1;return/^[A-Za-z0-9]+(\.[A-Za-z0-9]+)*@[a-zA-Z]([a-zA-Z0-9\-]*[a-zA-Z0-9])*(\.[a-zA-Z]([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*\.([a-zA-Z]+)*$/.test(t)},u=function(t){t=t.trim();return/^9\d{2}-\d{2}-\d{4}$/.test(t)},i=function(t){t=t.trim();return!!/^\d{2,6}$/.test(t)&&!!{11:!0,21:!0,22:!0,23:!0,31:!0,32:!0,33:!0,41:!0,42:!0,44:!0,45:!0,48:!0,49:!0,51:!0,52:!0,53:!0,54:!0,55:!0,56:!0,61:!0,62:!0,71:!0,72:!0,81:!0,91:!0,92:!0}[parseInt(t.substring(0,2),10)]},a=function(t){if(t.length>40||t.length<2)return!1;return/^[a-zA-Z0-9'.&,\-\s]*$/.test(t)},s=function(t){if(!t)return!1;return/^\S*$/.test(t)},f=function(t){t=t.trim();return/^[a-zA-Z0-9]{9}$/.test(t)},d=function(t){t=t.trim();if(!/^\d{9}$/.test(t))return!1;for(var r=0,n=0;n<t.length;n+=3)r+=3*parseInt(t.charAt(n),10)+7*parseInt(t.charAt(n+1),10)+parseInt(t.charAt(n+2),10);return r%10==0},c=function(t){t=t.trim();return/^[0-8]\d{2}-\d{2}-\d{4}$/.test(t)},A=function(t){t=t.trim();return/^[A-Za-z0-9]{8}([A-Za-z0-9]{3})?$/.test(t)},$=function(t){t=t.trim();return/^\d{5}(\d{4})?$/.test(t)};export{t as accountNumber,r as creditCard,n as ein,e as email,u as itin,i as naics,a as name,s as oneWord,f as passportNumber,d as routingNumber,c as ssn,A as swiftCode,$ as zip};