summaryrefslogtreecommitdiff
path: root/src/Controllers/ValidationController.php
blob: f90359ada9afb2534b5dd735910c24765912005b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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;
  }
}