简体   繁体   中英

Unique constraint on multiple fields in Doctrine MongoDB ODM in Symfony2

I have found Symfony\\Bundle\\DoctrineMongoDBBundle\\Validator\\Constraints\\Unique but it seems to be valid only for one field (found in this example: http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/form.html as class annotation). Is there any simple solution for such validation on more than one field?

Yes, but i`ve found simple solution - just add more than one @MongoDBUnique constraint works. Remember to separate @MongoDBUnique for each unique field, nor combining all fields into array as in @UniqueEntity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM