thanks, that worked for me but i still think it is a bug because after the refresh the exception disappears and the code is not validated anymore($form->isValid returns allways true in this case)
On Jun 2, 4:10 pm, Eriksen Costa <[email protected]> wrote: > Don't create code in the Symfony namespace. Use your namespace instead. If > your constraint validator does not have dependencies, you will not need to > configure a service (in services.yml). > > Simply put, your code should look like this: > > <?php > > namespace MYNSP\MyBundle\Validator; > > use Symfony\Component\Validator\Constraint; > > class Password extends Constraint > { > public $message = 'Passwords don`t match'; > > } > > namespace MYNSP\MyBundle\Validator; > > use Symfony\Component\Validator\Constraint; > use Symfony\Component\Validator\ConstraintValidator; > > class PasswordValidator extends ConstraintValidator > { > public function isValid($value, Constraint $constraint) > { > if ($value) { > $this->setMessage($constraint->message); > > return false; > } > > return false; > } > > } > > namespace MYNSP\MyBundle\Entity; > > use MYNSP\MyBundle\Validator\Password; > > class User > { > /** > * @Password > */ > protected $password; > > > > > > > > > > } > On Thu, Jun 2, 2011 at 9:15 AM, cosmin <[email protected]> wrote: > > 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 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 > > -- > Blog:http://eriksencosta.wordpress.com > Twitter: @eriksencosta -- 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
