2

I have this error. Help please.

I use this instruction http://symfony.com/doc/current/reference/constraints/Callback.html for 3.0 version (i use Symfony 3.0)

My validation.yml

App\Bundle\NameBundle\Entity\Product:
    constraints:
        - Callback: [validate]

Entity

namespace App\Bundle\NameBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
 * Product
 */
class Product
{
    /**
    * @var integer
     */
    private $id;

    /* ... some code .... */

     public function validate(ExecutionContextInterface $context)
     {
         $context->buildViolation('This name sounds totally fake!')
             ->atPath('firstName')
             ->addViolation();
     }
}

what am I doing wrong?

SOLUTION:

in validation.yml

...
- Callback: validate
...
2
  • Where is the actual error? What is going wrong? Where are you trying to apply this? etc. Commented Feb 2, 2016 at 21:09
  • i found solution, thank you Commented Feb 3, 2016 at 10:28

1 Answer 1

5

Error in string 3 validation.yml

    - Callback: [validate] #wrong
    - Callback: validate #right
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.