Le 02/06/2011 14:15, cosmin a écrit :
I tried to build my own custom validation and created @Assert/Password
i could not manage to figure out how to add the validator in
config.yml and because of this the first time i got this error
AnnotationException: [Semantical Error] The annotation "@Symfony
\Component\Validator\Constraints\Password" in property MYNSP\MyBundle
\Entity\User::$password does not exist, or could not be auto-loaded.
and after an refresh the error disapears and $form->isValid() returns
allways true even if it should return false
CODE::
namespace Symfony\Component\Validator\Constraints;
class Password extends \Symfony\Component\Validator\Constraint
{
public $message = 'Passwords don`t match';
}
namespace Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
class PasswordValidator extends ConstraintValidator
{
public function isValid($value, Constraint $constraint)
{
if (!condition) {
$this->setMessage($constraint->message);
return false;
}
return false;
}
}
If you create your own constraint, it should not be placed in the
Symfony\Component\Validator\Constraint namespace as this would require
putting the file in the Symfony code. (same is true for all classes you
create)
--
Christophe | Stof
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en