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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
<?php
namespace Kanboard\Validator;
use Kanboard\Core\Base;
use SimpleValidator\Validators;
/**
* Base Validator
*
* @package Kanboard\Validator
* @author Frederic Guillot
*/
abstract class BaseValidator extends 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);
}
/**
* Common password validation rules
*
* @access protected
* @return array
*/
protected function commonPasswordValidationRules()
{
return array(
new Validators\Required('password', t('The password is required')),
new Validators\MinLength('password', t('The minimum length is %d characters', 6), 6),
new Validators\Required('confirmation', t('The confirmation is required')),
new Validators\Equals('password', 'confirmation', t('Passwords don\'t match')),
);
}
}
|