validate-polish
Advanced tools
Comparing version 2.0.40 to 2.1.40
@@ -1,15 +0,1 @@ | ||
var validatePolish=function(r){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var t={checksum:function(r,t){for(var e=r.length-1,n=0,u=0;u<e;++u){n+=parseInt(r.charAt(u),10)*t[u]}var i=n%11;return(10===i?0:i)===parseInt(r.slice(-1),10)},pesel:function(r){var t=Number(r.substring(2,4));if(!t||t%20>12)return!1;var e=Number(r.substring(4,6));if(!e||e<1||e>31)return!1;if(!/^[0-9]{11}$/u.test(r))return!1;var n=[1,3,7,9],u=(""+r).split("").map((function(r){return parseInt(r,10)})),i=function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,u,i=e.call(r),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(r){u={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(u)throw u.error}}return a}(u.splice(-1),1)[0],a=u.reduce((function(r,t,e){return r+t*n[e%4]}))%10;return 10-(0===a?10:a)===i},nip:function(r){if("string"!=typeof r)return!1;var t=r.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(t))return!1;var e=String(t).split(""),n=[6,5,7,2,3,4,5,6,7].map((function(r,t){return r*parseInt(e[t],10)})),u=0;n.forEach((function(r){u+=r}));var i=u%11;return parseInt(e[9],10)===i},regon:function(r){if(!/^[0-9]{9,14}$/u.test(r))return!1;var e=[8,9,2,3,4,5,6,7];if(9===r.length)return t.checksum(r,e);return t.checksum(r.slice(0,9),e)&&t.checksum(r,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard:function(r){if(!r||9!==r.length)return!1;for(var t=r.toUpperCase(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=function(r){for(var t=0,n=e.length;t<n;t++)if(r===e[t])return t;return-1},u=0;u<3;++u)if(n(t[u])<10)return!1;for(u=3;u<9;++u)if(n(t[u])<0||n(t[u])>9)return!1;var i=7*n(t[0])+3*n(t[1])+Number(n(t[2]))+7*n(t[4])+3*n(t[5])+Number(n(t[6]))+7*n(t[7])+3*n(t[8]);return(i%=10)===n(t[3])},identityCardWithSeparator:function(r){return!(!r||10!==r.length)&&((" "===r[3]||"-"===r[3])&&this.identityCard(r.replace(/[\s-]/gu,"")))}};return r.validatePolish=t,Object.defineProperty(r,"__esModule",{value:!0}),r}({}); | ||
var validatePolish=function(t){"use strict";const e={checksum:(t,e)=>{const r=t.length-1;let n=0;for(let s=0;s<r;++s){n+=parseInt(t.charAt(s),10)*e[s]}const s=n%11;return(10===s?0:s)===parseInt(t.slice(-1),10)},pesel(t){const e=Number(t.substring(2,4));if(!e||e%20>12)return!1;const r=Number(t.substring(4,6));if(!r||r<1||r>31)return!1;if(!/^[0-9]{11}$/u.test(t))return!1;const n=[1,3,7,9],s=`${t}`.split("").map((t=>parseInt(t,10))),[u]=s.splice(-1),i=s.reduce(((t,e,r)=>t+e*n[r%4]))%10;return 10-(0===i?10:i)===u},nip(t){if("string"!=typeof t)return!1;const e=t.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(e))return!1;const r=String(e).split(""),n=[6,5,7,2,3,4,5,6,7].map(((t,e)=>t*parseInt(r[e],10)));let s=0;n.forEach((t=>{s+=t}));const u=s%11;return parseInt(r[9],10)===u},regon(t){if(!/^([0-9]{9}|[0-9]{14})$/u.test(t))return!1;const r=[8,9,2,3,4,5,6,7];if(9===t.length)return e.checksum(t,r);return e.checksum(t.slice(0,9),r)&&e.checksum(t,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard(t){if(!t||9!==t.length)return!1;const e=t.toUpperCase(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=t=>{for(let e=0,n=r.length;e<n;e++)if(t===r[e])return e;return-1};for(let t=0;t<3;++t)if(n(e[t])<10)return!1;for(let t=3;t<9;++t)if(n(e[t])<0||n(e[t])>9)return!1;let s=7*n(e[0])+3*n(e[1])+Number(n(e[2]))+7*n(e[4])+3*n(e[5])+Number(n(e[6]))+7*n(e[7])+3*n(e[8]);return s%=10,s===n(e[3])},identityCardWithSeparator(t){return!(!t||10!==t.length)&&((" "===t[3]||"-"===t[3])&&this.identityCard(t.replace(/[\s-]/gu,"")))}};return t.validatePolish=e,Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
export declare const validatePolish: { | ||
checksum: (number: string, weights: number[]) => boolean; | ||
/** | ||
* Validation of PESEL. | ||
*/ | ||
pesel(pesel: string): boolean; | ||
/** | ||
* Validation of NIP. | ||
*/ | ||
nip(nip: string): boolean; | ||
/** | ||
* Validation of REGON. | ||
*/ | ||
regon(regon: string): boolean; | ||
/** | ||
* Validation of identity card. | ||
*/ | ||
identityCard(num: string): boolean; | ||
/** | ||
* Checks if given number of identity card is valid. | ||
*/ | ||
identityCardWithSeparator(num: string): boolean; | ||
}; |
@@ -1,16 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r={checksum:function(r,t){for(var e=r.length-1,n=0,u=0;u<e;++u){n+=parseInt(r.charAt(u),10)*t[u]}var i=n%11;return(10===i?0:i)===parseInt(r.slice(-1),10)},pesel:function(r){var t=Number(r.substring(2,4));if(!t||t%20>12)return!1;var e=Number(r.substring(4,6));if(!e||e<1||e>31)return!1;if(!/^[0-9]{11}$/u.test(r))return!1;var n=[1,3,7,9],u=(""+r).split("").map((function(r){return parseInt(r,10)})),i= | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
function(r,t){var e="function"==typeof Symbol&&r[Symbol.iterator];if(!e)return r;var n,u,i=e.call(r),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(r){u={error:r}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(u)throw u.error}}return a}(u.splice(-1),1)[0],a=u.reduce((function(r,t,e){return r+t*n[e%4]}))%10;return 10-(0===a?10:a)===i},nip:function(r){if("string"!=typeof r)return!1;var t=r.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(t))return!1;var e=String(t).split(""),n=[6,5,7,2,3,4,5,6,7].map((function(r,t){return r*parseInt(e[t],10)})),u=0;n.forEach((function(r){u+=r}));var i=u%11;return parseInt(e[9],10)===i},regon:function(t){if(!/^[0-9]{9,14}$/u.test(t))return!1;var e=[8,9,2,3,4,5,6,7];if(9===t.length)return r.checksum(t,e);return r.checksum(t.slice(0,9),e)&&r.checksum(t,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard:function(r){if(!r||9!==r.length)return!1;for(var t=r.toUpperCase(),e=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=function(r){for(var t=0,n=e.length;t<n;t++)if(r===e[t])return t;return-1},u=0;u<3;++u)if(n(t[u])<10)return!1;for(u=3;u<9;++u)if(n(t[u])<0||n(t[u])>9)return!1;var i=7*n(t[0])+3*n(t[1])+Number(n(t[2]))+7*n(t[4])+3*n(t[5])+Number(n(t[6]))+7*n(t[7])+3*n(t[8]);return(i%=10)===n(t[3])},identityCardWithSeparator:function(r){return!(!r||10!==r.length)&&((" "===r[3]||"-"===r[3])&&this.identityCard(r.replace(/[\s-]/gu,"")))}};exports.validatePolish=r; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={checksum:(t,e)=>{const r=t.length-1;let n=0;for(let s=0;s<r;++s){n+=parseInt(t.charAt(s),10)*e[s]}const s=n%11;return(10===s?0:s)===parseInt(t.slice(-1),10)},pesel(t){const e=Number(t.substring(2,4));if(!e||e%20>12)return!1;const r=Number(t.substring(4,6));if(!r||r<1||r>31)return!1;if(!/^[0-9]{11}$/u.test(t))return!1;const n=[1,3,7,9],s=`${t}`.split("").map((t=>parseInt(t,10))),[u]=s.splice(-1),i=s.reduce(((t,e,r)=>t+e*n[r%4]))%10;return 10-(0===i?10:i)===u},nip(t){if("string"!=typeof t)return!1;const e=t.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(e))return!1;const r=String(e).split(""),n=[6,5,7,2,3,4,5,6,7].map(((t,e)=>t*parseInt(r[e],10)));let s=0;n.forEach((t=>{s+=t}));const u=s%11;return parseInt(r[9],10)===u},regon(e){if(!/^([0-9]{9}|[0-9]{14})$/u.test(e))return!1;const r=[8,9,2,3,4,5,6,7];if(9===e.length)return t.checksum(e,r);return t.checksum(e.slice(0,9),r)&&t.checksum(e,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard(t){if(!t||9!==t.length)return!1;const e=t.toUpperCase(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=t=>{for(let e=0,n=r.length;e<n;e++)if(t===r[e])return e;return-1};for(let t=0;t<3;++t)if(n(e[t])<10)return!1;for(let t=3;t<9;++t)if(n(e[t])<0||n(e[t])>9)return!1;let s=7*n(e[0])+3*n(e[1])+Number(n(e[2]))+7*n(e[4])+3*n(e[5])+Number(n(e[6]))+7*n(e[7])+3*n(e[8]);return s%=10,s===n(e[3])},identityCardWithSeparator(t){return!(!t||10!==t.length)&&((" "===t[3]||"-"===t[3])&&this.identityCard(t.replace(/[\s-]/gu,"")))}};exports.validatePolish=t; |
@@ -1,15 +0,1 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
var r={checksum:function(r,t){for(var n=r.length-1,e=0,u=0;u<n;++u){e+=parseInt(r.charAt(u),10)*t[u]}var i=e%11;return(10===i?0:i)===parseInt(r.slice(-1),10)},pesel:function(r){var t=Number(r.substring(2,4));if(!t||t%20>12)return!1;var n=Number(r.substring(4,6));if(!n||n<1||n>31)return!1;if(!/^[0-9]{11}$/u.test(r))return!1;var e=[1,3,7,9],u=(""+r).split("").map((function(r){return parseInt(r,10)})),i=function(r,t){var n="function"==typeof Symbol&&r[Symbol.iterator];if(!n)return r;var e,u,i=n.call(r),a=[];try{for(;(void 0===t||t-- >0)&&!(e=i.next()).done;)a.push(e.value)}catch(r){u={error:r}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(u)throw u.error}}return a}(u.splice(-1),1)[0],a=u.reduce((function(r,t,n){return r+t*e[n%4]}))%10;return 10-(0===a?10:a)===i},nip:function(r){if("string"!=typeof r)return!1;var t=r.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(t))return!1;var n=String(t).split(""),e=[6,5,7,2,3,4,5,6,7].map((function(r,t){return r*parseInt(n[t],10)})),u=0;e.forEach((function(r){u+=r}));var i=u%11;return parseInt(n[9],10)===i},regon:function(t){if(!/^[0-9]{9,14}$/u.test(t))return!1;var n=[8,9,2,3,4,5,6,7];if(9===t.length)return r.checksum(t,n);return r.checksum(t.slice(0,9),n)&&r.checksum(t,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard:function(r){if(!r||9!==r.length)return!1;for(var t=r.toUpperCase(),n=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],e=function(r){for(var t=0,e=n.length;t<e;t++)if(r===n[t])return t;return-1},u=0;u<3;++u)if(e(t[u])<10)return!1;for(u=3;u<9;++u)if(e(t[u])<0||e(t[u])>9)return!1;var i=7*e(t[0])+3*e(t[1])+Number(e(t[2]))+7*e(t[4])+3*e(t[5])+Number(e(t[6]))+7*e(t[7])+3*e(t[8]);return(i%=10)===e(t[3])},identityCardWithSeparator:function(r){return!(!r||10!==r.length)&&((" "===r[3]||"-"===r[3])&&this.identityCard(r.replace(/[\s-]/gu,"")))}};export{r as validatePolish}; | ||
const t={checksum:(t,e)=>{const r=t.length-1;let n=0;for(let s=0;s<r;++s){n+=parseInt(t.charAt(s),10)*e[s]}const s=n%11;return(10===s?0:s)===parseInt(t.slice(-1),10)},pesel(t){const e=Number(t.substring(2,4));if(!e||e%20>12)return!1;const r=Number(t.substring(4,6));if(!r||r<1||r>31)return!1;if(!/^[0-9]{11}$/u.test(t))return!1;const n=[1,3,7,9],s=`${t}`.split("").map((t=>parseInt(t,10))),[u]=s.splice(-1),i=s.reduce(((t,e,r)=>t+e*n[r%4]))%10;return 10-(0===i?10:i)===u},nip(t){if("string"!=typeof t)return!1;const e=t.replace(/-/gu,"");if(!/^[0-9]{10}$/u.test(e))return!1;const r=String(e).split(""),n=[6,5,7,2,3,4,5,6,7].map(((t,e)=>t*parseInt(r[e],10)));let s=0;n.forEach((t=>{s+=t}));const u=s%11;return parseInt(r[9],10)===u},regon(e){if(!/^([0-9]{9}|[0-9]{14})$/u.test(e))return!1;const r=[8,9,2,3,4,5,6,7];if(9===e.length)return t.checksum(e,r);return t.checksum(e.slice(0,9),r)&&t.checksum(e,[2,4,8,5,0,9,7,3,6,1,2,4,8])},identityCard(t){if(!t||9!==t.length)return!1;const e=t.toUpperCase(),r=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=t=>{for(let e=0,n=r.length;e<n;e++)if(t===r[e])return e;return-1};for(let t=0;t<3;++t)if(n(e[t])<10)return!1;for(let t=3;t<9;++t)if(n(e[t])<0||n(e[t])>9)return!1;let s=7*n(e[0])+3*n(e[1])+Number(n(e[2]))+7*n(e[4])+3*n(e[5])+Number(n(e[6]))+7*n(e[7])+3*n(e[8]);return s%=10,s===n(e[3])},identityCardWithSeparator(t){return!(!t||10!==t.length)&&((" "===t[3]||"-"===t[3])&&this.identityCard(t.replace(/[\s-]/gu,"")))}};export{t as validatePolish}; |
{ | ||
"name": "validate-polish", | ||
"version": "2.0.40", | ||
"description": "Utility library for validation of PESEL, NIP, REGON, identity card etc. Aimed mostly at Polish enviroment. [Polish] Walidacja numerów pesel, nip, regon, dowodu osobistego.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"pesel", | ||
"nip", | ||
"regon", | ||
"walidacja", | ||
"validation", | ||
"identity-card", | ||
"polish" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "Artur Kurowski <radarsu@gmail.com>", | ||
"homepage": "https://github.com/radarsu/validate-polish#readme", | ||
"main": "dist/index.js", | ||
"module": "dist/index.module.js", | ||
"browser": { | ||
"./dist/index.js": "./dist/index.browser.js", | ||
"./dist/index.module.js": "./dist/index.module.js" | ||
}, | ||
"types": "dist/index.d.ts", | ||
"devDependencies": { | ||
"@rollup/plugin-typescript": "^8.2.0", | ||
"@types/jest": "^26.0.21", | ||
"@types/node": "^14.14.37", | ||
"jest": "^26.6.3", | ||
"rollup": "^2.42.2", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.4" | ||
}, | ||
"gitHead": "5f409f3708573a20e3ce2e5088531dcd8951df7b" | ||
} | ||
"name": "validate-polish", | ||
"version": "2.1.40", | ||
"description": "Utility library for validation of PESEL, NIP, REGON, identity card etc. Aimed mostly at Polish environment. [Polish] Walidacja numerów pesel, nip, regon, dowodu osobistego.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"pesel", | ||
"nip", | ||
"regon", | ||
"walidacja", | ||
"validation", | ||
"identity-card", | ||
"polish" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"author": "Artur Kurowski <radarsu@gmail.com>", | ||
"homepage": "https://github.com/radarsu/validate-polish#readme", | ||
"main": "dist/index.js", | ||
"module": "dist/index.module.js", | ||
"browser": { | ||
"./dist/index.js": "./dist/index.browser.js", | ||
"./dist/index.module.js": "./dist/index.module.js" | ||
}, | ||
"types": "dist/index.d.ts", | ||
"dependencies": { | ||
"tslib": "2.4.1" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "29.3.1", | ||
"@rollup/plugin-typescript": "8.3.2", | ||
"@types/jest": "29.2.5", | ||
"@types/node": "18.11.18", | ||
"jest": "29.3.1", | ||
"jest-cli": "29.3.1", | ||
"rollup": "2.74.1", | ||
"rollup-plugin-terser": "7.0.2", | ||
"ts-jest": "29.0.3", | ||
"typescript": "4.9.4" | ||
}, | ||
"gitHead": "5f409f3708573a20e3ce2e5088531dcd8951df7b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34548
11
1
10
29
+ Addedtslib@2.4.1
+ Addedtslib@2.4.1(transitive)