Only check regex and equals when field is provided
parent
d70fd4357a
commit
4d20b7e2f3
|
@ -13,10 +13,7 @@ class FormValidator {
|
|||
}
|
||||
|
||||
foreach($this->fieldValidation as $field => $params) {
|
||||
if($params['required'] && (!isset($req[$field]) || strlen($req[$field]) == 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($req[$field]) && strlen(trim($req[$field])) > 0) {
|
||||
if(isset($params['regex'])) {
|
||||
if(!preg_match($params['regex'], $req[$field])) {
|
||||
return false;
|
||||
|
@ -26,6 +23,10 @@ class FormValidator {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else if($params['required']) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue