A simple regex based exhaustive validator for PIN codes in India
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
india-pincode-regex/src/Validator.php

21 lines
341 B

<?php
namespace PIN;
class Validator {
static $regexes;
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) {
return true;
}
}
return false;
}
}