india-pincode-regex/src/Validator.php

22 lines
341 B
PHP
Raw Normal View History

2020-02-24 18:02:18 +00:00
<?php
namespace PIN;
class Validator {
static $regexes;
2020-02-24 18:02:18 +00:00
public static function validate(string $pin) {
if(!self::$regexes) {
self::$regexes = array_filter(file('regex.txt'));
}
foreach (self::$regexes as $regex) {
if (strlen($pin) === 6 and preg_match($regex, $pin) === 1) {
2020-02-24 18:02:18 +00:00
return true;
}
}
return false;
}
}