FieldValidator::isValid()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 1
nc 1
1
<?php
2
3
namespace fieldwork\validators;
4
5
use fieldwork\Synchronizable;
6
7
abstract class FieldValidator implements Synchronizable
8
{
9
10
    private $errorMsg = '', $field;
11
12
    public function __construct ($errorMsg)
13
    {
14
        $this->errorMsg = $errorMsg;
15
    }
16
17
    public function getJsonData ()
18
    {
19
        return array(
20
            'error'  => $this->errorMsg,
21
            'method' => $this->describeObject()
22
        );
23
    }
24
25
    public function setField ($f)
26
    {
27
        $this->field = $f;
28
    }
29
30
    public function getField ()
31
    {
32
        return $this->field;
33
    }
34
35
    public function getErrorMsg ()
36
    {
37
        return $this->errorMsg;
38
    }
39
40
    public abstract function isValid ($value);
41
42
    /**
43
     * Whether to skip the remaining field validators
44
     *
45
     * @param string $value
46
     *
47
     * @return bool
48
     */
49
    public function skipValidation ($value)
50
    {
51
        return false;
52
    }
53
54
}