I am currently developing a Website in which user may buy gift cards. I am using a three step form using the CraueFormFlow bundle and everything is concerning the steps. I a
You have many solutions for this.
The easiest one is to add a Callback constraint to your model class.
Another way to do it would be to create your custom constraint and its associated validator. You have a cookbook explaining how to create a custom validation constrain. This is the best approach to do it.
As your constraint does not apply to a property but to a class, you must specify it overriding the the ->getTargets()
method of your constraint class:
class MyConstraint extends Constraint
{
// ...
public function getTargets()
{
return Constraint::CLASS_CONSTRAINT;
}
}
So the value passed as $value
argument of the ->isValid()
method will contain values of the whole class and not only of a single property.