diff options
Diffstat (limited to 'src/Validator.php')
-rw-r--r-- | src/Validator.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Validator.php b/src/Validator.php index 33cdf34..03d09b8 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -51,7 +51,7 @@ class Validator return $result; } - public function validateFields(array $fields): array + private function validateFields(array $fields): array { /**@var Utilities $utilities*/ global $utilities; @@ -71,8 +71,14 @@ class Validator return $fields; } - public function validateSingleField(array $field): array + private function validateSingleField(array $field): array { + /**@var HookManager $hooks*/ + global $hooks; + + /**@var Form $form*/ + global $form; + $value = $_POST[$field['name']] ?? ''; $field['is_valid'] = true; @@ -84,10 +90,10 @@ class Validator $field['is_valid'] = false; } - $validationFunctionName = 'validate_' . basename($this->formPath) . '_' . $field['name']; - if (function_exists($validationFunctionName)) { - $field = call_user_func($validationFunctionName, $field, $value); - } + $field = $hooks->applyFilter("validator:{$form->name}:field", $field, $value); + $field = $hooks->applyFilter("validator:{$form->name}:field:{$field['name']}", $field, $value); + $field = $hooks->applyFilter("validator:field:{$field['name']}", $field, $value); + $field = $hooks->applyFilter('validator:field', $field, $value); return $field; } |