2020-02-25 08:50:53 +00:00
|
|
|
const readline = require("readline");
|
|
|
|
const fs = require("fs");
|
|
|
|
|
2020-03-13 12:19:02 +00:00
|
|
|
const regexes = fs
|
|
|
|
.readFileSync(__dirname + "/../regex.txt", "utf8")
|
2020-03-13 11:12:58 +00:00
|
|
|
.split("\n")
|
|
|
|
// Remove empty lines
|
2020-03-13 12:19:02 +00:00
|
|
|
.filter(function(r) {
|
|
|
|
return r.length > 1;
|
|
|
|
})
|
2020-03-13 11:12:58 +00:00
|
|
|
// Remove the opening and closing slashes
|
2020-03-13 12:19:02 +00:00
|
|
|
.map(function(r) {
|
|
|
|
return new RegExp("^" + r.slice(1, -1) + "$");
|
|
|
|
});
|
2020-02-25 08:50:53 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
validate: function(pin) {
|
|
|
|
for (let i in regexes) {
|
|
|
|
if (regexes[i].test(pin)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2020-03-13 11:12:58 +00:00
|
|
|
};
|