Errors
class Errors implements IteratorAggregate (View source)
Class that holds {@link Validations} errors.
Properties
static | $DEFAULT_ERROR_MESSAGES |
Methods
Nulls $model so we don't get pesky circular references. $model is only needed during the validation process and so can be safely cleared once that is done.
Add an error message.
Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.
Retrieve error messages for an attribute.
Adds the error message only if the attribute value was null or an empty string.
Returns true if the specified attribute had any error messages.
Returns the error message(s) for the specified attribute or null if none.
Returns the internal errors object.
Returns all the error messages as an array.
Returns all the error messages as an array, including error key.
Convert all error messages to a String.
Returns true if there are no error messages.
Clears out all error messages.
Returns the number of error messages there are.
Returns an iterator to the error messages.
Details
at line 673
clear_model()
Nulls $model so we don't get pesky circular references. $model is only needed during the validation process and so can be safely cleared once that is done.
at line 684
add(string $attribute, string $msg)
Add an error message.
at line 701
add_on_empty(string $attribute, string $msg)
Adds an error message only if the attribute value is {@link http://www.php.net/empty empty}.
at line 716
array
__get(string $attribute)
Retrieve error messages for an attribute.
at line 730
add_on_blank(string $attribute, string $msg)
Adds the error message only if the attribute value was null or an empty string.
at line 745
boolean
is_invalid(string $attribute)
Returns true if the specified attribute had any error messages.
at line 756
string/array
on(string $attribute)
Returns the error message(s) for the specified attribute or null if none.
at line 775
get_raw_errors()
Returns the internal errors object.
$model->errors->get_raw_errors();
array(
"name" => array("can't be blank"),
"state" => array("is the wrong length (should be 2 chars)",
)
at line 794
array
full_messages()
Returns all the error messages as an array.
$model->errors->full_messages();
array(
"Name can't be blank",
"State is the wrong length (should be 2 chars)"
)
at line 822
array
to_array(callable $closure = null)
Returns all the error messages as an array, including error key.
$model->errors->errors();
array(
"name" => array("Name can't be blank"),
"state" => array("State is the wrong length (should be 2 chars)")
)
at line 856
string
__toString()
Convert all error messages to a String.
This function is called implicitely if the object is casted to a string:
echo $error;
"Name can't be blank\nState is the wrong length (should be 2 chars)"
at line 865
boolean
is_empty()
Returns true if there are no error messages.
at line 873
clear()
Clears out all error messages.
at line 882
int
size()
Returns the number of error messages there are.
at line 907
ArrayIterator
getIterator()
Returns an iterator to the error messages.
This will allow you to iterate over the {@link Errors} object using foreach.
foreach ($model->errors as $msg)
echo "$msg\n";