Table of Contents
ValidationResult
Layer: Validator · Source: lib/validator/ValidationResult.php:19 (lines 19–106)
class ValidationResult
Value object carrying validation result.
Replaces the ($checkError, $errors) tuple pattern used throughout controllers with a single immutable result.
Docblock Metadata
| Tag | Value |
|---|---|
@category | Validator |
@author | M.Noermoehammad |
@license | MIT |
@version | 1.0 |
@since | Since Release 1.0 |
Inheritance
No parent, interface or trait. This is a root type.
Constants (0)
None.
Properties (2)
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
private | (untyped) | $errors | [] | 22 |
private | (untyped) | $valid | true | 25 |
Methods (7)
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public | addError() | Add a single error message. | 33 |
| public | merge() | Merge another ValidationResult into this one. | 46 |
| public | isValid() | Whether validation passed. | 59 |
| public | getErrors() | Return all error messages. | 69 |
| public static | success() | Factory: successful validation. | 79 |
| public static | failure() | Factory: failed validation with one message. | 90 |
| public | hasErrors() | Whether there are any errors. | 102 |
addError()
public function addError($message)
lines 33–38 (6)
Add a single error message.
| Parameter | Type | Default | Description |
|---|---|---|---|
$message | (untyped) | required | none |
Returns: (none declared) — self
merge()
public function merge(ValidationResult $other)
lines 46–52 (7)
Merge another ValidationResult into this one.
| Parameter | Type | Default | Description |
|---|---|---|---|
$other | ''ValidationResult'' | required | none |
Returns: (none declared) — self
isValid()
public function isValid()
lines 59–62 (4)
Whether validation passed.
Takes no parameters.
Returns: (none declared) — bool
getErrors()
public function getErrors()
lines 69–72 (4)
Return all error messages.
Takes no parameters.
Returns: (none declared) — array
success()
public static function success()
lines 79–82 (4)
Factory: successful validation.
Takes no parameters.
Returns: (none declared) — self
failure()
public static function failure($message)
lines 90–95 (6)
Factory: failed validation with one message.
| Parameter | Type | Default | Description |
|---|---|---|---|
$message | (untyped) | required | none |
Returns: (none declared) — self
hasErrors()
public function hasErrors()
lines 102–105 (4)
Whether there are any errors.
Takes no parameters.
Returns: (none declared) — bool
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.
