Slide 92
Slide 92 text
namespace Shop\Constraints;
use Shop\Address;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
class NorthAmericaStateValidator extends ConstraintValidator
{
private static $regions = [
'US' => [ 'NV', 'CA', 'DC', 'FL', 'VG', 'NY', 'OR', … ],
'CA' => [ 'QC', 'AB', … ],
];
public function validate($value, Constraint $constraint)
{
// ...
}
}