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