Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon\Validation get failed fields

When validation is done, there is a list of messages returned. Is there a way to get the fields whose validations are failed? Not just a list of messages.


        $this->add('name', new PresenceOf(array(
            'message' => 'The name is required'

        $this->add('email', new PresenceOf(array(
            'message' => 'The e-mail is required'

        $this->add('email', new Email(array(
            'message' => 'The e-mail is not valid'

If third validation is failed, how can I know that email is not good, but name is fine?


please take a look phalcon docs

you can get failed field name using this code

$messages = $validation->validate();
if (count($messages)) {
    foreach ($validation->getMessages() as $message) {
        echo "Message: ", $message->getMessage(), "\n";
        echo "Field: ", $message->getField(), "\n";
        echo "Type: ", $message->getType(), "\n";


I'm sorry... it did read that doc but for some reason didn't see that info. Just need to sleep more :)