summaryrefslogtreecommitdiff
path: root/src/Validator.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-03-06 11:45:31 +0100
committerDaniel Weipert <code@drogueronin.de>2022-03-06 11:45:31 +0100
commit1334236bb6059b2302a760196ce7885df379e984 (patch)
treef86e883e6ae9510454307f38be3ffd20aefa6c4c /src/Validator.php
parentad83d1dafac62bb28fda004f86129319a5c3e2ca (diff)
toml to yaml
Diffstat (limited to 'src/Validator.php')
-rw-r--r--src/Validator.php18
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;
}