validate-polish
Advanced tools
Comparing version 2.0.39 to 2.0.40
@@ -15,2 +15,2 @@ var validatePolish=function(r){"use strict"; | ||
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[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<1||t>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 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}({}); |
@@ -1,2 +0,2 @@ | ||
"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[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<1||t>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= | ||
"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= | ||
/*! ***************************************************************************** | ||
@@ -3,0 +3,0 @@ Copyright (c) Microsoft Corporation. |
@@ -15,2 +15,2 @@ /*! ***************************************************************************** | ||
***************************************************************************** */ | ||
var r={checksum:function(r,t){for(var n=r.length-1,e=0,u=0;u<n;++u){e+=parseInt(r[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<1||t>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}; | ||
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}; |
{ | ||
"name": "validate-polish", | ||
"version": "2.0.39", | ||
"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.", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
"@types/jest": "^26.0.21", | ||
"@types/node": "^14.14.35", | ||
"@types/node": "^14.14.37", | ||
"jest": "^26.6.3", | ||
@@ -36,5 +36,5 @@ "rollup": "^2.42.2", | ||
"ts-jest": "^26.5.4", | ||
"typescript": "^4.2.3" | ||
"typescript": "^4.2.4" | ||
}, | ||
"gitHead": "9abd1f655dfcb6980b73f313ae1ce39324eed2a2" | ||
"gitHead": "5f409f3708573a20e3ce2e5088531dcd8951df7b" | ||
} |
@@ -8,5 +8,5 @@ <p align="center"> | ||
1. [Usage](#usage) | ||
1. [Getting Started](#getting-started) | ||
2. [Getting Started](#getting-started) | ||
2. [Usage](#usage) | ||
@@ -17,2 +17,6 @@ 3. [Features](#features) | ||
## Getting Started | ||
`npm i validate-polish` | ||
## Usage | ||
@@ -53,6 +57,2 @@ ### General | ||
## Getting Started | ||
`npm i validate-polish` | ||
## Features | ||
@@ -64,4 +64,4 @@ - **CDN** - available via cdn (https://cdn.jsdelivr.net/npm/validate-polish@latest/dist/index.browser.js) | ||
- **Strongly typed** - library written fully in TypeScript | ||
- **Supports PESEL, REGON (9 and 14), NIP, IDENTITY CARD** | ||
- **Supports PESEL, REGON (9 and 14), NIP, IDENTITY CARD** - also validates day and month correctness including century encoded in month. | ||
- **Tested** - has tests on dozens of valid and invalid chunks of data to make sure validations are performed flawlessly | ||
@@ -6,3 +6,3 @@ - **CDN** - available via cdn (https://cdn.jsdelivr.net/npm/validate-polish@latest/dist/index.browser.js) | ||
- **Strongly typed** - library written fully in TypeScript | ||
- **Supports PESEL, REGON (9 and 14), NIP, IDENTITY CARD** | ||
- **Supports PESEL, REGON (9 and 14), NIP, IDENTITY CARD** - also validates day and month correctness including century encoded in month. | ||
- **Tested** - has tests on dozens of valid and invalid chunks of data to make sure validations are performed flawlessly |
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
14568