1 | <?php |
||
21 | class Result implements ResultInterface |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Boolean flag to indicate overall failure or success |
||
26 | * |
||
27 | * @var bool |
||
28 | */ |
||
29 | protected $result; |
||
30 | |||
31 | /** |
||
32 | * Contains an array of errors that occurred during validation |
||
33 | * |
||
34 | * @var string[] |
||
35 | */ |
||
36 | protected $errors = array(); |
||
37 | |||
38 | /** |
||
39 | * Contains the rule that caused a given field to fail |
||
40 | * |
||
41 | * @var RuleInterface[] |
||
42 | */ |
||
43 | protected $failedRules = array(); |
||
44 | |||
45 | /** |
||
46 | * Contains a list of fields that passed validation |
||
47 | * |
||
48 | * @var string[] |
||
49 | */ |
||
50 | protected $validated = array(); |
||
51 | |||
52 | /** |
||
53 | * @param bool $isValid |
||
54 | * |
||
55 | * @return $this |
||
56 | * |
||
57 | * @since 2.0 |
||
58 | */ |
||
59 | 17 | public function setResult($isValid) |
|
65 | |||
66 | /** |
||
67 | * @return bool |
||
68 | * |
||
69 | * @since 2.0 |
||
70 | */ |
||
71 | 16 | public function isValid() |
|
75 | |||
76 | /** |
||
77 | * @param string $field |
||
78 | * |
||
79 | * @return string |
||
80 | * @throws InvalidFieldException |
||
81 | * |
||
82 | * @since 2.0 |
||
83 | */ |
||
84 | 3 | public function getError($field) |
|
93 | |||
94 | /** |
||
95 | * @return string[] |
||
96 | * |
||
97 | * @since 2.0 |
||
98 | */ |
||
99 | 3 | public function getErrors() |
|
103 | |||
104 | /** |
||
105 | * Sets the error message for the given field |
||
106 | * |
||
107 | * @param string $field |
||
108 | * @param string $message |
||
109 | * @param string $rule |
||
110 | * |
||
111 | * @return $this |
||
112 | * |
||
113 | * @since 2.0 |
||
114 | */ |
||
115 | 8 | public function setError($field, $message, $rule) |
|
122 | |||
123 | /** |
||
124 | * @return string[] |
||
125 | * |
||
126 | * @since 2.0 |
||
127 | */ |
||
128 | 3 | public function getValidated() |
|
132 | |||
133 | /** |
||
134 | * @param string $field |
||
135 | * |
||
136 | * @return $this |
||
137 | * |
||
138 | * @since 2.0 |
||
139 | */ |
||
140 | 12 | public function setValidated($field) |
|
146 | |||
147 | /** |
||
148 | * Returns a list of rules that caused fields to fail, indexed by the field name. |
||
149 | * |
||
150 | * @return RuleInterface[] |
||
151 | * |
||
152 | * @since 2.0 |
||
153 | */ |
||
154 | 3 | public function getFailedRules() |
|
158 | |||
159 | /** |
||
160 | * {@inheritdoc} |
||
161 | */ |
||
162 | 2 | public function merge(ResultInterface $resultInterface, $fieldPrefix = '') |
|
186 | } |
||
187 |