summaryrefslogtreecommitdiff
path: root/src/Controllers/ValidationController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Controllers/ValidationController.php')
-rw-r--r--src/Controllers/ValidationController.php26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/Controllers/ValidationController.php b/src/Controllers/ValidationController.php
new file mode 100644
index 0000000..f90359a
--- /dev/null
+++ b/src/Controllers/ValidationController.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace FlatFileForms\Controllers;
+
+use FlatFileForms\Builder;
+use FlatFileForms\Validator;
+
+class ValidationController
+{
+ public function validateRequest(Builder $builder, Validator $validator): array
+ {
+ /**@var Utilities $utilities*/
+ global $utilities;
+
+ $fields = $builder->buildFields($_GET['page'] ?? null);
+
+ $result = $validator->validateRequest($fields);
+
+ $content['data'] = $result['fields'];
+ if (! empty($result['error'])) {
+ $content['error'] = $result['error'];
+ }
+
+ return $content;
+ }
+}