I'm using Symfony 2.6 and I'm following these tutorials how to use the validation callback constraint:
http://symfony.com/blog/new-in-symfony-2-4-a-better-callback-constraint
http://symfony.com/doc/current/reference/constraints/Callback.html#external-callbacks-and-closures
To invoke an external validation call I'm trying to use following yaml configuration:
App\APIBundle\Entity\Order:
properties:
id:
- Type:
type: integer
message: "Der Wert {{ value }} ist kein gültiger {{ type }}."
amount:
- Type:
type: integer
message: "Der Wert {{ value }} ist kein gültiger {{ type }}."
groups: [ "AppOrder", "AppOrderbasket" ]
- Callback: [App\APIBundle\Validator\Validator, validate]
groups: [ "AppOrder", "AppOrderbasket" ]
I run into following problems when trying to validate the amount property with an external callback validation class:
The function "validate" within the validation class App\APIBundle\Validator\Validator doesn't get invoked at all. I've tried to add validation groups by adding the "groups" property to the callback constraint. This seems not to be valid as i get this warning (Warning: trim() expects parameter 1 to be string, array given);
If I remove the "groups" property the warning dissapears but the validator is still not invoked.
Any ideas?
Thanks in advance
ninsky