diff options
author | Daniel Weipert <code@drogueronin.de> | 2022-01-05 23:12:23 +0100 |
---|---|---|
committer | Daniel Weipert <code@drogueronin.de> | 2022-01-10 11:29:13 +0100 |
commit | d6c5c7735e3207ead7759375e444bc6b72045e49 (patch) | |
tree | bcaded65f8279dde16750699cd7bbf4886a94e20 /src/App.php | |
parent | 43ec8517cbc42093ad1f17063495f79e6eddf1cf (diff) |
Validate fields by pattern and add more example fields
Diffstat (limited to 'src/App.php')
-rw-r--r-- | src/App.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/App.php b/src/App.php index a155017..1a12f6a 100644 --- a/src/App.php +++ b/src/App.php @@ -257,9 +257,14 @@ class App */ public function validateSingleField($field) { + $value = $_POST[$field['name']] ?? ''; $field['is_valid'] = true; - if (($field['required'] ?? false) && empty($_POST[$field['name']])) { + if (isset($field['required']) && empty($value)) { + $field['is_valid'] = false; + } + + if (isset($field['validation']['pattern']) && preg_match_all('/' . $field['validation']['pattern'] . '/', $value) === 0) { $field['is_valid'] = false; } |