I have an app built on top of Silex and I'm using Doctrine as my ORM.
I have a problem where I'm trying to get a clean error for when a user tries to reuse an email, I found the validator UniqueEntity but it seems to be designed for the full stack version of Symfony.
My question is, is this true? I'm going a limb and assuming it as I haven't found anyone who successfully used it outside of Symfony.
My second question is, if I'm not able to use UniqueEntity, whats my next best option? I'm using the Symfony Validator component and would like to use something that's plugged into that to keep it all in the same block of code.
You can use UniqueEntity with Silex.
Here's the service provider package with the Doctrine
ManagerRegistryimplementation - saxulum/saxulum-doctrine-orm-manager-registry-provider. Also you can find the instructions how to use it with theUniqueEntityvalidator in README.But you may want to implement you own
UniqueEntityvalidator.For example, if you want to validate DTO object (or any non-entity object), because it's not supported by Symfony's
UniqueEntityvalidator (see issue on GitHub).