Skip to content

Commit

Permalink
Merge branch '1.3' of github.com:cakephp/cakephp1x into 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 4, 2010
2 parents a726f82 + e4fa475 commit 32113a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
9 changes: 8 additions & 1 deletion cake/console/templates/default/classes/model.ctp
Expand Up @@ -42,7 +42,14 @@ if (!empty($validate)):
foreach ($validate as $field => $validations):
echo "\t\t'$field' => array(\n";
foreach ($validations as $key => $validator):
echo "\t\t\t'$key' => array('rule' => array('$validator')),\n";
echo "\t\t\t'$key' => array(\n";
echo "\t\t\t\t'rule' => array('$validator'),\n";
echo "\t\t\t\t//'message' => 'Your custom message here',\n";
echo "\t\t\t\t//'allowEmpty' => false,\n";
echo "\t\t\t\t//'required' => false,\n";
echo "\t\t\t\t//'last' => false, // Stop validation after this rule\n";
echo "\t\t\t\t//'on' => 'create', // Limit validation to 'create' or 'update' operations\n";
echo "\t\t\t),\n";
endforeach;
echo "\t\t),\n";
endforeach;
Expand Down
15 changes: 13 additions & 2 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -594,8 +594,19 @@ function testBakeValidation() {
$this->assertPattern('/class Article extends AppModel \{/', $result);
$this->assertPattern('/\$name \= \'Article\'/', $result);
$this->assertPattern('/\$validate \= array\(/', $result);
$pattern = '/' . preg_quote("'notempty' => array('rule' => array('notempty')),", '/') . '/';
$this->assertPattern($pattern, $result);
$expected = <<< STRINGEND
array(
'notempty' => array(
'rule' => array('notempty'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
STRINGEND;

$this->assertPattern('/' . preg_quote($expected, '/') . '/', $result);
}

/**
Expand Down

0 comments on commit 32113a4

Please sign in to comment.