Merge branch '211-plate-number-validation' into 'master'
Resolve "Plate number validation" Closes #211 See merge request jankstudio/resq!247
This commit is contained in:
commit
6501f6c0e3
1 changed files with 27 additions and 20 deletions
|
|
@ -162,30 +162,37 @@ class Warranty
|
|||
// trim and make upper case
|
||||
$clean_plate = strtoupper(trim($plate));
|
||||
|
||||
// remove invalid characters
|
||||
$clean_plate = preg_replace("/[^A-Z0-9]/", '', $clean_plate);
|
||||
|
||||
// check for 4 to 5 digit diplomatic plate
|
||||
$res = preg_match("/^[0-9]{4,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// ABC-1234 or ABC-123 or ABC-12 format
|
||||
$res = preg_match("/^[A-Z]{3}[0-9]{2,4}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// AB-123 or AB-12345 or AB-1234 format (motorcycles)
|
||||
$res = preg_match("/^[A-Z]{2}[0-9]{3,5}$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
// 1234-AB format (motorcycles)
|
||||
$res = preg_match("/^[0-9]{4}[A-Z]{2}$/", $clean_plate);
|
||||
// check if alphanumeric, max length is 11, no spaces
|
||||
$res = preg_match("/^[A-Z0-9]{1,11}+$/", $clean_plate);
|
||||
if ($res)
|
||||
return $clean_plate;
|
||||
|
||||
return false;
|
||||
|
||||
// remove invalid characters
|
||||
//$clean_plate = preg_replace("/[^A-Z0-9]/", '', $clean_plate);
|
||||
|
||||
// check for 4 to 5 digit diplomatic plate
|
||||
//$res = preg_match("/^[0-9]{4,5}$/", $clean_plate);
|
||||
//if ($res)
|
||||
// return $clean_plate;
|
||||
|
||||
// ABC-1234 or ABC-123 or ABC-12 format
|
||||
//$res = preg_match("/^[A-Z]{3}[0-9]{2,4}$/", $clean_plate);
|
||||
//if ($res)
|
||||
// return $clean_plate;
|
||||
|
||||
// AB-123 or AB-12345 or AB-1234 format (motorcycles)
|
||||
//$res = preg_match("/^[A-Z]{2}[0-9]{3,5}$/", $clean_plate);
|
||||
//if ($res)
|
||||
// return $clean_plate;
|
||||
|
||||
// 1234-AB format (motorcycles)
|
||||
//$res = preg_match("/^[0-9]{4}[A-Z]{2}$/", $clean_plate);
|
||||
//if ($res)
|
||||
// return $clean_plate;
|
||||
|
||||
//return false;
|
||||
}
|
||||
|
||||
public function setPlateNumber($plate)
|
||||
|
|
|
|||
Loading…
Reference in a new issue