Example #1
0
 /**
  * Validator method used to check the uniqueness of a value for a column.
  * This is meant to be used with the validation API and not to be called
  * directly.
  *
  * ### Example:
  *
  * {{{
  * $validator->add('email', [
  *    'unique' => ['rule' => 'validateUnique', 'provider' => 'table']
  * ])
  * }}}
  *
  * Unique validation can be scoped to the value of another column:
  *
  * {{{
  * $validator->add('email', [
  *    'unique' => [
  *        'rule' => ['validateUnique', ['scope' => 'site_id']],
  *        'provider' => 'table'
  *    ]
  * ]);
  * }}}
  *
  * In the above example, the email uniqueness will be scoped to only rows having
  * the same site_id. Scoping will only be used if the scoping field is present in
  * the data to be validated.
  *
  * @override To allow multiple scoped values
  *
  * @param mixed $value The value of column to be checked for uniqueness
  * @param array $options The options array, optionally containing the 'scope' key
  * @param array $context The validation context as provided by the validation routine
  * @return bool true if the value is unique
  */
 public function validateUniqueExt($value, array $options, array $context = [])
 {
     $context += $options;
     return parent::validateUnique($value, $context);
 }