How can I get a simple array of errors when validating a form?
My code:
$validate = Validation::factory();
$validate->add_field('email', 'Email address', 'required');
$validate->add_field('password', 'Password', 'required');
if(!$validate->run()) {
print_r($validate->errors());
} else {
echo 'success';
}
I was expecting a simple array of errors, however I get a mass of recursive arrays and a debug message
P.S. The code button doesn't seem to work
Errors are returned as Validation_Error objects, they have a __toString() method so if you just echo them (or cast to string in another way) they'll output as the error messages you're expecting.