ValidationResult
class ValidationResult implements Serializable
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
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 |
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.
Create a new ValidationResult.
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
Returns true if the result is valid.
Return the full error meta-data, suitable for combining with another ValidationResult.
Combine this Validation Result with the ValidationResult given in other.
String representation of object
Constructs the object
Details
in Injectable at line 26
static Injectable
create(array $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'); $list = SiteTree::get();
in Injectable at line 43
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).
at line 70
__construct()
Create a new ValidationResult.
By default, it is a successful result. Call $this->error() to record errors.
at line 102
$this
addError(string $message, string $messageType = self::TYPE_ERROR, string $code = null, string|bool $cast = self::CAST_TEXT)
Record an error against this validation result,
at line 120
$this
addFieldError(string $fieldName, string $message, string $messageType = self::TYPE_ERROR, string $code = null, string|bool $cast = self::CAST_TEXT)
Record an error against this validation result,
at line 143
$this
addMessage(string $message, string $messageType = self::TYPE_ERROR, string $code = null, string|bool $cast = self::CAST_TEXT)
Add a message to this ValidationResult without necessarily marking it as an error
at line 161
$this
addFieldMessage(string $fieldName, string $message, string $messageType = self::TYPE_ERROR, string $code = null, string|bool $cast = self::CAST_TEXT)
Add a message to this ValidationResult without necessarily marking it as an error
at line 194
boolean
isValid()
Returns true if the result is valid.
at line 204
array
getMessages()
Return the full error meta-data, suitable for combining with another ValidationResult.
at line 217
$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.
at line 229
string
serialize()
String representation of object
at line 239
unserialize(string $serialized)
Constructs the object