summaryrefslogtreecommitdiff
path: root/src/App.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-01-05 23:12:23 +0100
committerDaniel Weipert <code@drogueronin.de>2022-01-10 11:29:13 +0100
commitd6c5c7735e3207ead7759375e444bc6b72045e49 (patch)
treebcaded65f8279dde16750699cd7bbf4886a94e20 /src/App.php
parent43ec8517cbc42093ad1f17063495f79e6eddf1cf (diff)
Validate fields by pattern and add more example fields
Diffstat (limited to 'src/App.php')
-rw-r--r--src/App.php7
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;
}