Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Exist Validator for composite keys #2212

romandi opened this Issue · 3 comments

4 participants


Please, implement a composite key uniqueness validation. Something like this:

array(array('tag_id', 'post_id'), 'unique', 'message'=>'{attribute}:{value} already exists!')


Is this really needed? How often described use case could happen? Maybe it's better to make such validation through custom model method?


Agree with issuestarter. This feature is often needed. For example, when table that represents bridge at MANY_MANY relation has its own model, fields and attributes (except foreign keys).
If there is validator for non-composite PK's, why not to use the same validator for composite keys?


It's better to be done via custom validator, which isn't too difficult a task.
The problem with composite key validation is that it is about validating multiple attributes simultaneously, and you need to configure many things in order to make it really work. Ultimately you will find the configuration is not less trivial than writing a custom validator. In fact, if you search our extension repository, you will not be able to find such a validator, which explains this partially.

@qiangxue qiangxue closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.