yii1-extended/yii1-multiple-unique-validator

A validator that validates that a multi-column value is unique


Keywords
validator, multiple, index, primary key, unique, Yii1, multi-column
License
MIT

Documentation

yii1-multiple-unique-validator

A validator that validates that a multi-column value is unique

Installation

The installation of this library is made via composer. Download composer.phar from their website. Then add to your composer.json :

	"require": {
		...
		"yii1-extended/yii1-multiple-unique-validator": "^1",
		...
	}

Then run php composer.phar update to install this library. The autoloading of all classes of this library is made through composer's autoloader.

Basic Usage

In the model validation :


public function rules()
{
  return array(
    ...
    array('<attribute names>', 'CMultipleUniqueValidator', 'attributeList' => array(
    		'<attribute1>', '<attribute2>', ...
    )),
    ...
  );
}

This validator validates that the given attribute tuple is unique. For example, if we have an unique index (or primary key) on the fields ("field1", "field2, "field3"), then this validator will ensure that the values represented by ($model->field1, $model->field2, $model->field3) is unique into the related table of the database.

If no attributeList is provided, or only one field is present, this validator falls back on the CUniqueValidator which is a core validator.

License

MIT (See license file).