Le 03/06/2011 05:44, agomez a écrit :
Does not work

File: AG\WebdemoBundle\Validator\PasswordAG.php

<?php
namespace AG\WebdemoBundle\Validator;

use Symfony\Component\Validator\Constraint;

class PasswordAG extends Constraint
{
    public $message = 'Passwords don`t match';
}
?>

File: AG\WebdemoBundle\Validator\PasswordAGValidator.php

<?php

namespace AG\WebdemoBundle\Validator;

use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;

class PasswordAGValidator extends ConstraintValidator
{
    public function isValid($value, Constraint $constraint)
    {
        if ($value) {
            $this->setMessage($constraint->message);
            return false;
        }
        return false;
    }
}
?>

File: AG\WebdemoBundle\Resources\validation.yml

# Edudata/PortalBundle/Resources/config/validation.yml
AG\WebdemoBundle\Entity\Usuario:
   properties:
     usuaRut:
       - NotBlank: {message: "Debe ingresar un valor"}
       - Min: {limit: 9, message: "Debe ser un valor de mínimo 9
caracteres"}
     usuaPassword:
       - NotBlank: {message: "Debe ingresar un valor"}
       - Min: {limit: 9, message: "Debe ser un valor de mínimo 8
caracteres"}
       - PasswordAG: {message: "Probando"}


File: AG\WebdemoBundle\Entity\Usuario
<?php

namespace AG\WebdemoBundle\Entity;

use AG\WebdemoBundle\Validator\PasswordAG;
/**
  * AG\WebdemoBundle\Entity\Usuario
  */
class Usuario
{
     /**
      * @var integer $usuaId
      */
     private $usuaId;

     /**
      * @var integer $usuaRut
      */
     private $usuaRut;

     /**
      * @var string $usuaDv
      */
     private $usuaDv;

     /**
      * @var string $usuaNombre
      */
     private $usuaNombre;

     /**
      * @var string $usuaPassword
      */
     private $usuaPassword;


Thanks

  AG
You are asking the validator to use a PasswordAG constraint from the default namespace, not form your own location. The correct syntax is this one: https://gist.github.com/994273 (using the Doctrine UniqueEntity valdiator here)

--
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

Reply via email to