UNPKG

@ifoxxie_dev/brdoc-validator

Version:

A TypeScript validator for brdoc documents, ensuring compliance with the brdoc schema.

1 lines 1.01 kB
var t={d:(r,e)=>{for(var n in e)t.o(e,n)&&!t.o(r,n)&&Object.defineProperty(r,n,{enumerable:!0,get:e[n]})},o:(t,r)=>Object.prototype.hasOwnProperty.call(t,r)},r={};function e(t){if("string"!=typeof t)return!1;if(14!==(t=t.replace(/[^\d]+/g,"")).length)return!1;if(/^(\d)\1{13}$/.test(t))return!1;const r=[5,4,3,2,9,8,7,6,5,4,3,2];let e=0;for(let n=0;n<12;n++)e+=parseInt(t.charAt(n))*r[n];let n=e%11;if((n<2?0:11-n)!==parseInt(t.charAt(12)))return!1;const a=[6].concat(r);e=0;for(let r=0;r<13;r++)e+=parseInt(t.charAt(r))*a[r];return n=e%11,(n<2?0:11-n)===parseInt(t.charAt(13))}function n(t){if("string"!=typeof t)return!1;if(11!==(t=t.replace(/[^\d]+/g,"")).length)return!1;if(/^(\d)\1{10}$/.test(t))return!1;let r=0;for(let e=0;e<9;e++)r+=parseInt(t.charAt(e))*(10-e);let e=r%11;if((e<2?0:11-e)!==parseInt(t.charAt(9)))return!1;r=0;for(let e=0;e<10;e++)r+=parseInt(t.charAt(e))*(11-e);return e=r%11,(e<2?0:11-e)===parseInt(t.charAt(10))}t.d(r,{q:()=>e,i:()=>n});var a=r.q,o=r.i;export{a as isCnpj,o as isCpf};