summaryrefslogtreecommitdiff
path: root/app/Validator/Base.php
blob: 6c56e2fde246b89de22fe3705e8f53190ee4daa6 (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
27
28
29
30
31
32
33
34
35
36
<?php

namespace Kanboard\Validator;

/**
 * Base Validator
 *
 * @package  validator
 * @author   Frederic Guillot
 */
class Base extends \Kanboard\Core\Base
{
    /**
     * Execute multiple validators
     *
     * @access public
     * @param  array  $validators       List of validators
     * @param  array  $values           Form values
     * @return array  $valid, $errors   [0] = Success or not, [1] = List of errors
     */
    public function executeValidators(array $validators, array $values)
    {
        $result = false;
        $errors = array();

        foreach ($validators as $method) {
            list($result, $errors) = $this->$method($values);

            if (! $result) {
                break;
            }
        }

        return array($result, $errors);
    }
}