Permalink
Browse files

Make rule sniff less complicated and tidy up doc block.

Refs #4871
  • Loading branch information...
markstory committed Oct 13, 2014
1 parent 1ded0c2 commit 50b3893e6507979427e1aaeb435494aed1af4f52
Showing with 7 additions and 3 deletions.
  1. +6 −2 lib/Cake/Model/Model.php
  2. +1 −1 lib/Cake/Test/Case/Model/ModelValidationTest.php
View
@@ -3302,8 +3302,12 @@ public function resetAssociations() {
*/
public function isUnique($fields, $or = true) {
if (is_array($or)) {
- $isAssociative = count(array_filter(array_keys($or), 'is_string'));
- if (!$isAssociative) {
+ $isRule = (
+ array_key_exists('rule', $or) &&
+ array_key_exists('required', $or) &&
+ array_key_exists('message', $or)
+ );
+ if (!$isRule) {
$args = func_get_args();
$fields = $args[1];
$or = isset($args[2]) ? $args[2] : true;
@@ -2450,7 +2450,7 @@ public function testIsUniqueValidator() {
}
/**
- * Test backward compatibility of the isUnique method when used as a validator for multiple fields.
+ * Test backward compatibility of the isUnique method when used as a validator for a single field.
*
* @return void
*/

0 comments on commit 50b3893

Please sign in to comment.