Tuesday, 10 September 2013

Symfony 2 Validation Constraint for Foregin Key

Symfony 2 Validation Constraint for Foregin Key

I am building an Restful API where say 'userId' / 'addressId' are POST/PUT
(between other fileds) and these fields are foreign keys in the DB.
My question is about Symfony Validation Component as I want to validate if
those id's are valid.
This, I think, need to be a 'Doctrine' validator as it will need to query
the related tables.
I checked the existing validators and it seems that none of them cover
this case, in fact, it is only one Doctrine validator
(UniqueEntityValidator)
I am writing a custom validatior at this stage.. but did anyone else find
the same issue ? Is it not any standard Symfony/Doctrine validator
available for this case?

No comments:

Post a Comment