How to validate a field itself?

so, its ok to validate the form - but how to validate an induvidial item?

edited Dec '15

Not sure if it's what you're asking : after a form has been validated you can access field by field result :

if(!$form->isValid($data, $entity)) {
    $field = 'nameofthefield';
    if($form->hasMessagesFor($field)) {
        var_dump($form->getMessagesFor($field));
    }
}


11.3k

I wanted to see a

<?php
$name = new Text("name");
$name->addValidator(
    new PresenceOf(
        array(
            'message' => 'The name is required'
        )
    )
);
$name->whatMethodShouldITypeHereWhatSendsMeTrueOrFalseItTheInputIsValidOrNot() ?