From 1334236bb6059b2302a760196ce7885df379e984 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 6 Mar 2022 11:45:31 +0100 Subject: toml to yaml --- src/Validator.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/Validator.php') 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; } -- cgit v1.2.3