ValidationResult deprecated
class ValidationResult (View source)
deprecated
A class that combined as a boolean result with an optional list of error messages.
This is used for returning validation results from validators
Each message can have a code or field which will uniquely identify that message. However, messages can be stored without a field or message as an "overall" message.
Traits
A class that can be instantiated or replaced via DI
Constants
TYPE_ERROR |
Standard "error" type |
TYPE_GOOD |
Standard "good" message type |
TYPE_INFO |
Non-error message type. |
TYPE_WARNING |
Warning message type |
CAST_HTML |
Message type is html |
CAST_TEXT |
Message type is plain text |
Properties
protected | bool | $isValid | Is the result valid or not. |
|
protected | array | $messages | List of messages |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Record an error against this validation result,
Record an error against this validation result,
Add a message to this ValidationResult without necessarily marking it as an error
Add a message to this ValidationResult without necessarily marking it as an error
Return the full error meta-data, suitable for combining with another ValidationResult.
Combine this Validation Result with the ValidationResult given in other.
Details
static Injectable
create(mixed ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
__construct()
No description
$this
addError(string $message, string $messageType = ValidationResult::TYPE_ERROR, string $code = null, string|bool $cast = ValidationResult::CAST_TEXT)
Record an error against this validation result,
$this
addFieldError(string $fieldName, string $message, string $messageType = ValidationResult::TYPE_ERROR, string $code = null, string|bool $cast = ValidationResult::CAST_TEXT)
Record an error against this validation result,
$this
addMessage(string $message, string $messageType = ValidationResult::TYPE_ERROR, string $code = null, string|bool $cast = ValidationResult::CAST_TEXT)
Add a message to this ValidationResult without necessarily marking it as an error
$this
addFieldMessage(string $fieldName, string $message, string $messageType = ValidationResult::TYPE_ERROR, string $code = null, string|bool $cast = ValidationResult::CAST_TEXT)
Add a message to this ValidationResult without necessarily marking it as an error
bool
isValid()
Returns true if the result is valid.
array
getMessages()
Return the full error meta-data, suitable for combining with another ValidationResult.
$this
combineAnd(ValidationResult $other)
Combine this Validation Result with the ValidationResult given in other.
It will be valid if both this and the other result are valid. This object will be modified to contain the new validation information.
array
__serialize()
No description
void
__unserialize(array $data)
No description