UNPKG

validate-kaike-js

Version:
3 lines (2 loc) 6.17 kB
var n=[{country:"AF",name:"Afghanistan",regex:/^\d{4}-\d{4}-\d{5}$/},{country:"AO",name:"Angola",regex:/^\d{9}[A-Z]{2}\d{3}$/},{country:"AR",name:"Argentina",regex:/^\d{2}\.\d{3}\.\d{3}$/},{country:"AU",name:"Australia",regex:/^\d{9}$/},{country:"BR",name:"Brazil",regex:/^\d{3}\.\d{3}\.\d{3}-\d{2}$/},{country:"CA",name:"Canada",regex:/^\d{3}-\d{3}-\d{3}$/},{country:"CN",name:"China",regex:/^\d{17}[\dX]$/},{country:"DE",name:"Germany",regex:/^\d{11}$/},{country:"ES",name:"Spain",regex:/^[XYZ]?\d{7,8}[A-Z]$/},{country:"FR",name:"France",regex:/^\d{13}$/},{country:"GB",name:"United Kingdom",regex:/^[A-Z]{2}\d{6}[A-Z]$/},{country:"IN",name:"India",regex:/^\d{12}$/},{country:"IT",name:"Italy",regex:/^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/},{country:"JP",name:"Japan",regex:/^\d{12}$/},{country:"MX",name:"Mexico",regex:/^[A-Z]{4}\d{6}[HM]\d{5}$/},{country:"PT",name:"Portugal",regex:/^\d{8}$/},{country:"RU",name:"Russia",regex:/^\d{2} \d{2} \d{6}$/},{country:"US",name:"United States",regex:/^\d{3}-\d{2}-\d{4}$/},{country:"ZA",name:"South Africa",regex:/^\d{13}$/}];var d=[{provider:"Generic Email",regex:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/},{provider:"Gmail",regex:/^[a-zA-Z0-9._%+-]+@gmail\.com$/},{provider:"Hotmail/Outlook",regex:/^[a-zA-Z0-9._%+-]+@(hotmail|outlook)\.com$/},{provider:"Yahoo",regex:/^[a-zA-Z0-9._%+-]+@yahoo\.(com|co\.uk|fr|de)$/},{provider:"ProtonMail",regex:/^[a-zA-Z0-9._%+-]+@protonmail\.com$/},{provider:"Yandex",regex:/^[a-zA-Z0-9._%+-]+@yandex\.ru$/},{provider:"iCloud",regex:/^[a-zA-Z0-9._%+-]+@icloud\.com$/},{provider:"Zoho Mail",regex:/^[a-zA-Z0-9._%+-]+@zohomail\.com$/},{provider:"GMX",regex:/^[a-zA-Z0-9._%+-]+@gmx\.(com|de)$/},{provider:"Mail.ru",regex:/^[a-zA-Z0-9._%+-]+@(mail|inbox|list|bk)\.ru$/},{provider:"Japan (docomo)",regex:/^[a-zA-Z0-9._%+-]+@docomo\.ne\.jp$/},{provider:"China (163.com)",regex:/^[a-zA-Z0-9._%+-]+@163\.com$/},{provider:"Brazil (UOL)",regex:/^[a-zA-Z0-9._%+-]+@uol\.com\.br$/},{provider:"South Korea (Naver)",regex:/^[a-zA-Z0-9._%+-]+@naver\.com$/},{provider:"Germany (Web.de)",regex:/^[a-zA-Z0-9._%+-]+@web\.de$/},{provider:"France (Orange)",regex:/^[a-zA-Z0-9._%+-]+@orange\.fr$/},{provider:"United Kingdom (BT Internet)",regex:/^[a-zA-Z0-9._%+-]+@btinternet\.com$/}];var a=[{country:"AF",regex:/^AF\d{2}\d{16}$/},{country:"AO",regex:/^AO\d{23}$/},{country:"AR",regex:/^AR\d{2}\d{20}$/},{country:"AU",regex:/^AU\d{2}\d{6}\d{10}$/},{country:"BR",regex:/^BR\d{25}[A-Z]{1}[A-Z0-9]{1}$/},{country:"CA",regex:/^CA\d{2}\d{18}$/},{country:"CN",regex:/^CN\d{2}\d{18}$/},{country:"DE",regex:/^DE\d{20}$/},{country:"ES",regex:/^ES\d{22}$/},{country:"FR",regex:/^FR\d{12}[A-Z0-9]{11}\d{2}$/},{country:"GB",regex:/^GB\d{2}[A-Z]{4}\d{14}$/},{country:"IN",regex:/^IN\d{2}\d{18}$/},{country:"IT",regex:/^IT\d{2}[A-Z]\d{10}[A-Z0-9]{12}$/},{country:"JP",regex:/^JP\d{2}\d{18}$/},{country:"MX",regex:/^MX\d{2}\d{18}$/},{country:"PT",regex:/^PT\d{23}$/},{country:"RU",regex:/^RU\d{2}\d{20}$/},{country:"US",regex:/^US\d{2}\d{18}$/},{country:"ZA",regex:/^ZA\d{2}\d{18}$/}];var g=[{country:"AF",regex:/^[A-Z]{2}\d{7}$/},{country:"AO",regex:/^[A-Z]{2}\d{6}$/},{country:"AR",regex:/^[A-Z]\d{7}$/},{country:"AU",regex:/^[A-Z]\d{7}$/},{country:"BR",regex:/^[A-Z]{2}\d{6}$/},{country:"CA",regex:/^[A-Z]{2}\d{6}$/},{country:"CN",regex:/^G\d{8}$|^E\d{8}$/},{country:"DE",regex:/^[CFGHJKLMNPRTVWXYZ0-9]{9}$/},{country:"ES",regex:/^[A-Z]{3}\d{6}$/},{country:"FR",regex:/^[0-9]{2}[A-Z]{2}[0-9]{5}$/},{country:"GB",regex:/^\d{9}$/},{country:"IN",regex:/^[A-Z]{1}-\d{7}$/},{country:"IT",regex:/^[A-Z0-9]{9}$/},{country:"JP",regex:/^[A-Z]{2}\d{7}$/},{country:"MX",regex:/^\d{10}$/},{country:"PT",regex:/^[A-Z]\d{6}$/},{country:"RU",regex:/^\d{9}$/},{country:"US",regex:/^\d{9}$/},{country:"ZA",regex:/^[A-Z]{2}\d{6}$/}];var c=[{country:"+93",regex:/^(\+93)[7-9]\d{8}$/},{country:"+244",regex:/^(\+244)[9]\d{8}$/},{country:"+54",regex:/^(\+54)[1-9]\d{9}$/},{country:"+61",regex:/^(\+61)[2-9]\d{8}$/},{country:"+55",regex:/^(\+55)[1-9]{2}9?[6-9]\d{7}$/},{country:"+1",regex:/^(\+1)[2-9]\d{9}$/},{country:"+86",regex:/^(\+86)[1-9]\d{9}$/},{country:"+49",regex:/^(\+49)[1-9]\d{9,10}$/},{country:"+34",regex:/^(\+34)[6-7]\d{8}$/},{country:"+33",regex:/^(\+33)[6-7]\d{8}$/},{country:"+44",regex:/^(\+44)7\d{9}$/},{country:"+91",regex:/^(\+91)[6-9]\d{9}$/},{country:"+39",regex:/^(\+39)[3]\d{9}$/},{country:"+81",regex:/^(\+81)[7-9]\d{8}$/},{country:"+52",regex:/^(\+52)[1-9]\d{9}$/},{country:"+351",regex:/^(\+351)[9]\d{8}$/},{country:"+7",regex:/^(\+7)[9]\d{9}$/},{country:"+27",regex:/^(\+27)[6-8]\d{8}$/}];var z=async e=>{let t=await Promise.allSettled(e.map(({fn:o,input:u,country:i,provider:x,phoneCountryCode:s})=>new Promise((y,$)=>{try{y(o({input:u,country:i,provider:x,phoneCountryCode:s}))}catch(m){$(m)}}))),r=t.filter(o=>o.status==="rejected").map(o=>o.reason);return r.length>0?Promise.reject(r):Promise.resolve(t.map(o=>o.value))},I=({input:e,provider:t})=>{let r=d.find(o=>o.provider===t);if(!r)throw{message:`${t} not supported`,value:e};if(r.regex.test(e))return{message:`Valid ${t}`,value:e};throw{message:`Invalid ${t}`,value:e}},_=({input:e,country:t})=>{let r=n.find(o=>o.country===t);if(!r)throw{message:"Country not supported",value:e};if(r.regex.test(e))return{message:"Valid identity card",value:e};throw{message:"Invalid identity card",value:e}},U=({input:e,country:t})=>{let r=a.find(o=>o.country===t);if(!r)throw{message:"Country not supported",value:e};if(r.regex.test(e))return{message:"Valid IBAN",value:e};throw{message:"Invalid IBAN",value:e}},E=({input:e,country:t})=>{let r=g.find(o=>o.country===t);if(!r)throw{message:"Country not supported",value:e};if(r.regex.test(e))return{message:"Valid Passport",value:e};throw{message:"Invalid Passport",value:e}},w=({input:e,phoneCountryCode:t})=>{let r=c.find(o=>o.country===t);if(!r)throw{message:"Phone country code not supported",value:e};if(r.regex.test(e))return{message:"Valid phone country code",value:e};throw{message:"Invalid phone country code",value:e}};export{z as validate,I as validateEmail,U as validateIban,_ as validateIdentityCard,E as validatePassort,w as validatePhoneCountryCode}; //# sourceMappingURL=index.js.map