Skip to content

Commit

Permalink
fix: some fixes to isIdentityCard('he-IL') (#1048)
Browse files Browse the repository at this point in the history
* added support for IL in isIdentityCard()

* fix ci

* fix CI #2

* fix CI #3

* fix conflicts

* chnage locale to 'he-IL'

* change regex and if statments

remove inefficient code.

* remove if statement ,its not needed.

* fix eslit problem
  • Loading branch information
perimiter authored and profnandaa committed Jun 20, 2019
1 parent 7735e0f commit dcb2db0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
8 changes: 1 addition & 7 deletions lib/isIdentityCard.js
Expand Up @@ -33,7 +33,7 @@ var validators = {
return sanitized.endsWith(controlDigits[number % 23]);
},
'he-IL': function heIL(str) {
var DNI = /^\d+$/; // sanitize user input
var DNI = /^\d{9}$/; // sanitize user input

var sanitized = str.trim(); // validate the data structure

Expand All @@ -42,12 +42,6 @@ var validators = {
}

var id = sanitized;

if (id.length !== 9 || isNaN(id)) {
// Make sure ID is formatted properly
return false;
}

var sum = 0,
incNum;

Expand Down
6 changes: 1 addition & 5 deletions src/lib/isIdentityCard.js
Expand Up @@ -31,7 +31,7 @@ const validators = {
return sanitized.endsWith(controlDigits[number % 23]);
},
'he-IL': (str) => {
const DNI = /^\d+$/;
const DNI = /^\d{9}$/;

// sanitize user input
const sanitized = str.trim();
Expand All @@ -43,10 +43,6 @@ const validators = {

const id = sanitized;

if (id.length !== 9 || isNaN(id)) {
// Make sure ID is formatted properly
return false;
}
let sum = 0,
incNum;
for (let i = 0; i < id.length; i++) {
Expand Down
8 changes: 1 addition & 7 deletions validator.js
Expand Up @@ -1137,7 +1137,7 @@ var validators = {
return sanitized.endsWith(controlDigits[number % 23]);
},
'he-IL': function heIL(str) {
var DNI = /^\d+$/; // sanitize user input
var DNI = /^\d{9}$/; // sanitize user input

var sanitized = str.trim(); // validate the data structure

Expand All @@ -1146,12 +1146,6 @@ var validators = {
}

var id = sanitized;

if (id.length !== 9 || isNaN(id)) {
// Make sure ID is formatted properly
return false;
}

var sum = 0,
incNum;

Expand Down
2 changes: 1 addition & 1 deletion validator.min.js

Large diffs are not rendered by default.

0 comments on commit dcb2db0

Please sign in to comment.