ValidationError
in package
Represents an error detected while validating an element. This class contains information to aid a user of the system to solve the errors encountered and generating a valid input that is useful.
Tags
Table of Contents
- $extendedMessage : string
- The additional information the system has available to help the user solve the error in case they could need it.
- $message : string
- The message given to the user to help fix the error. This is simply a message indicating what the error has been.
- $src : mixed
- A reference to the element generating the error. This allows assigning the data and writing it next to the correct fields in case this behavior is wanted.
- $subErrors : array<string|int, ValidationError>
- A list of errors that are part of this error. This is useful when a field requires several validations like passwords or usernames which may generate several errors at once.
- __construct() : mixed
- Creates a new validation error. This represents an error during validation and holds information that should be helpful to resolve the source of it without the need of support. All the parameters except the error message are optional.
- __toString() : mixed
- getExtendedMessage() : string
- Provides additional information about the error the data the user typed in has generated. This is an extended version of the message and should also provide useful help on solving the kind of error.
- getMessage() : string
- Gets the error message that explains the source of this in a user friendly fashion. This message is meant to be delivered tot he end user of the system.
- getSrc() : mixed
- Returns a reference to the element that generated the error. This allows to check where the error originated and print error data next to the data input we're using to read the data.
- getSubErrors() : array<string|int, ValidationError>
- Returns a list of suberrors that this error may have generated. This allows you to specify several error information data in a single form control.
- putSubError() : ValidationError
- Adds a suberror to the object.
- setExtendedMessage() : mixed
- This message holds additional information to help the user fixing the data they provided to a form or whatever they used to enter data.
- setMessage() : mixed
- Sets the message the user receives as reason why the data was rejected. This information is meant to provide him with means to fix the issue.
- setSrc() : mixed
- Holds a reference to the source of the error. This will aid printing the error data next to the input where it generated, making it easier for the users to spot where they entered invalid data.
- setSubErrors() : ValidationError
- Defines a list of suberrors to this one to make this error 'composite'. It will provide a list of errors that all happened as part of this one.
Properties
$extendedMessage
The additional information the system has available to help the user solve the error in case they could need it.
private
string
$extendedMessage
Tags
$message
The message given to the user to help fix the error. This is simply a message indicating what the error has been.
private
string
$message
Tags
$src
A reference to the element generating the error. This allows assigning the data and writing it next to the correct fields in case this behavior is wanted.
private
mixed
$src
The source has been deprecated, the idea is that the source should be in charge of aggregating errors generated by it and provide these to the components that may need it.
Tags
$subErrors
A list of errors that are part of this error. This is useful when a field requires several validations like passwords or usernames which may generate several errors at once.
private
array<string|int, ValidationError>
$subErrors
This field also became deprecated in favor of having an array of ValidationErrors in every ValidationException when it is raised.
Tags
Methods
__construct()
Creates a new validation error. This represents an error during validation and holds information that should be helpful to resolve the source of it without the need of support. All the parameters except the error message are optional.
public
__construct(string $message[, string $extendedMessage = '' ][, mixed &$src = null ]) : mixed
Parameters
- $message : string
- $extendedMessage : string = ''
- $src : mixed = null
Return values
mixed —__toString()
public
__toString() : mixed
Return values
mixed —getExtendedMessage()
Provides additional information about the error the data the user typed in has generated. This is an extended version of the message and should also provide useful help on solving the kind of error.
public
getExtendedMessage() : string
Return values
string —getMessage()
Gets the error message that explains the source of this in a user friendly fashion. This message is meant to be delivered tot he end user of the system.
public
getMessage() : string
Return values
string —getSrc()
Returns a reference to the element that generated the error. This allows to check where the error originated and print error data next to the data input we're using to read the data.
public
getSrc() : mixed
Return values
mixed —getSubErrors()
Returns a list of suberrors that this error may have generated. This allows you to specify several error information data in a single form control.
public
getSubErrors() : array<string|int, ValidationError>
Return values
array<string|int, ValidationError> —putSubError()
Adds a suberror to the object.
public
putSubError(ValidationError $subError) : ValidationError
Parameters
- $subError : ValidationError
Return values
ValidationError —setExtendedMessage()
This message holds additional information to help the user fixing the data they provided to a form or whatever they used to enter data.
public
setExtendedMessage(string $extendedMessage) : mixed
Parameters
- $extendedMessage : string
Return values
mixed —setMessage()
Sets the message the user receives as reason why the data was rejected. This information is meant to provide him with means to fix the issue.
public
setMessage(string $message) : mixed
Parameters
- $message : string
Return values
mixed —setSrc()
Holds a reference to the source of the error. This will aid printing the error data next to the input where it generated, making it easier for the users to spot where they entered invalid data.
public
setSrc(mixed &$src) : mixed
Parameters
- $src : mixed
Return values
mixed —setSubErrors()
Defines a list of suberrors to this one to make this error 'composite'. It will provide a list of errors that all happened as part of this one.
public
setSubErrors(array<string|int, ValidationError> $subErrors) : ValidationError
Parameters
- $subErrors : array<string|int, ValidationError>