Skip to content

Commit

Permalink
Changed default validation error message to be rule neutral
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryan Crowe committed Aug 15, 2013
1 parent 7b407f8 commit 78c3e6a
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Model/Validator/ValidationSet.php
Expand Up @@ -425,7 +425,7 @@ protected function _processValidationResponse($name, $rule) {
$message = __d($this->_validationDomain, $name);
}
} else {
$message = __d('cake', 'This field cannot be left blank');
$message = __d('cake', 'The provided value is invalid');
}

return $message;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/TestCase/Controller/ControllerTest.php
Expand Up @@ -805,7 +805,7 @@ public function testValidateErrorsOnArbitraryModels() {
$Post->set('title', '');
$result = $TestController->validateErrors($Post);

$expected = array('title' => array('This field cannot be left blank'));
$expected = array('title' => array('The provided value is invalid'));
$this->assertEquals($expected, $result);
}

Expand Down
Expand Up @@ -963,7 +963,7 @@ public function testValidation() {
);
$TestModel->create();
$this->assertFalse($TestModel->save($data));
$this->assertEquals(array('This field cannot be left blank'), $TestModel->validationErrors['title']);
$this->assertEquals(array('The provided value is invalid'), $TestModel->validationErrors['title']);

$TestModel->locale = 'eng';
$TestModel->validate['title'] = '/Only this title/';
Expand Down
64 changes: 32 additions & 32 deletions lib/Cake/Test/TestCase/Model/ModelValidationTest.php
Expand Up @@ -155,29 +155,29 @@ public function testInvalidFieldsWithFieldListParams() {
$TestModel->set(array('title' => '$$', 'name' => '##'));
$TestModel->invalidFields(array('fieldList' => array('title')));
$expected = array(
'title' => array('This field cannot be left blank')
'title' => array('The provided value is invalid')
);
$this->assertEquals($expected, $TestModel->validationErrors);
$TestModel->validationErrors = array();

$TestModel->invalidFields(array('fieldList' => array('name')));
$expected = array(
'name' => array('This field cannot be left blank')
'name' => array('The provided value is invalid')
);
$this->assertEquals($expected, $TestModel->validationErrors);
$TestModel->validationErrors = array();

$TestModel->invalidFields(array('fieldList' => array('name', 'title')));
$expected = array(
'name' => array('This field cannot be left blank'),
'title' => array('This field cannot be left blank')
'name' => array('The provided value is invalid'),
'title' => array('The provided value is invalid')
);
$this->assertEquals($expected, $TestModel->validationErrors);
$TestModel->validationErrors = array();

$TestModel->whitelist = array('name');
$TestModel->invalidFields();
$expected = array('name' => array('This field cannot be left blank'));
$expected = array('name' => array('The provided value is invalid'));
$this->assertEquals($expected, $TestModel->validationErrors);

$this->assertEquals($TestModel->validate, $validate);
Expand All @@ -203,7 +203,7 @@ public function testInvalidFieldsWhitelist() {
$TestModel->whitelist = array('name');
$TestModel->save(array('name' => '#$$#', 'title' => '$$$$'));

$expected = array('name' => array('This field cannot be left blank'));
$expected = array('name' => array('The provided value is invalid'));
$this->assertEquals($expected, $TestModel->validationErrors);
}

Expand Down Expand Up @@ -586,7 +586,7 @@ public function testValidatesWithAssociations() {

$JoinThing->validate = array('doomed' => array('rule' => 'notEmpty'));

$expectedError = array('doomed' => array('This field cannot be left blank'));
$expectedError = array('doomed' => array('The provided value is invalid'));

$Something->create();
$result = $Something->save($data);
Expand Down Expand Up @@ -639,7 +639,7 @@ public function testValidatesWithModelsAndSaveAll() {
$JoinThing = $Something->JoinThing;

$JoinThing->validate = array('doomed' => array('rule' => 'notEmpty'));
$expectedError = array('doomed' => array('This field cannot be left blank'));
$expectedError = array('doomed' => array('The provided value is invalid'));

$Something->create();
$result = $Something->saveAll($data, array('validate' => 'only'));
Expand Down Expand Up @@ -1182,7 +1182,7 @@ public function testSaveAllDeepValidateOnly() {
'Comment' => array(
1 => array(
'Attachment' => array(
'attachment' => array('This field cannot be left blank')
'attachment' => array('The provided value is invalid')
)
)
)
Expand Down Expand Up @@ -1252,7 +1252,7 @@ public function testSaveAllDeepValidateOnly() {
'Comment' => array(
'Article' => array(
'User' => array(
'user' => array('This field cannot be left blank')
'user' => array('The provided value is invalid')
)
)
)
Expand All @@ -1278,9 +1278,9 @@ public function testSaveAllDeepValidateOnly() {
$expected = array(
'Comment' => array(
'Article' => array(
'body' => array('This field cannot be left blank'),
'body' => array('The provided value is invalid'),
'User' => array(
'user' => array('This field cannot be left blank')
'user' => array('The provided value is invalid')
)
)
)
Expand All @@ -1305,11 +1305,11 @@ public function testSaveAllDeepValidateOnly() {
$result = $TestModel->Comment->Attachment->validationErrors;
$expected = array(
'Comment' => array(
'comment' => array('This field cannot be left blank'),
'comment' => array('The provided value is invalid'),
'Article' => array(
'body' => array('This field cannot be left blank'),
'body' => array('The provided value is invalid'),
'User' => array(
'user' => array('This field cannot be left blank')
'user' => array('The provided value is invalid')
)
)
)
Expand All @@ -1333,13 +1333,13 @@ public function testSaveAllDeepValidateOnly() {

$result = $TestModel->Comment->Attachment->validationErrors;
$expected = array(
'attachment' => array('This field cannot be left blank'),
'attachment' => array('The provided value is invalid'),
'Comment' => array(
'comment' => array('This field cannot be left blank'),
'comment' => array('The provided value is invalid'),
'Article' => array(
'body' => array('This field cannot be left blank'),
'body' => array('The provided value is invalid'),
'User' => array(
'user' => array('This field cannot be left blank')
'user' => array('The provided value is invalid')
)
)
)
Expand All @@ -1348,11 +1348,11 @@ public function testSaveAllDeepValidateOnly() {

$result = $TestModel->Comment->validationErrors;
$expected = array(
'comment' => array('This field cannot be left blank'),
'comment' => array('The provided value is invalid'),
'Article' => array(
'body' => array('This field cannot be left blank'),
'body' => array('The provided value is invalid'),
'User' => array(
'user' => array('This field cannot be left blank')
'user' => array('The provided value is invalid')
)
)
);
Expand Down Expand Up @@ -1394,7 +1394,7 @@ public function testSaveAllNotDeepValidateOnly() {
$result = $TestModel->validateAssociated($data, array('deep' => false));
$this->assertFalse($result);

$expected = array('body' => array('This field cannot be left blank'));
$expected = array('body' => array('The provided value is invalid'));
$result = $TestModel->validationErrors;
$this->assertSame($expected, $result);

Expand Down Expand Up @@ -1625,8 +1625,8 @@ public function testValidateAssociated() {
$this->assertSame($expected, $result);

$expected = array('Comment' => array(
0 => array('comment' => array('This field cannot be left blank')),
2 => array('comment' => array('This field cannot be left blank'))
0 => array('comment' => array('The provided value is invalid')),
2 => array('comment' => array('The provided value is invalid'))
));
$this->assertEquals($expected['Comment'], $TestModel->Comment->validationErrors);

Expand All @@ -1636,9 +1636,9 @@ public function testValidateAssociated() {
$model->Attachment->validate = array('attachment' => 'notEmpty');
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
$expected = array(
'comment' => array('This field cannot be left blank'),
'comment' => array('The provided value is invalid'),
'Attachment' => array(
'attachment' => array('This field cannot be left blank')
'attachment' => array('The provided value is invalid')
)
);

Expand Down Expand Up @@ -1668,7 +1668,7 @@ public function testValidateMany() {
2 => array('title' => 'title 2'),
);
$expected = array(
0 => array('title' => array('This field cannot be left blank')),
0 => array('title' => array('The provided value is invalid')),
);

$result = $TestModel->saveAll($data, array('validate' => 'only'));
Expand All @@ -1684,7 +1684,7 @@ public function testValidateMany() {
2 => array('title' => 'title 2'),
);
$expected = array(
1 => array('title' => array('This field cannot be left blank')),
1 => array('title' => array('The provided value is invalid')),
);
$result = $TestModel->saveAll($data, array('validate' => 'only'));
$this->assertFalse($result);
Expand Down Expand Up @@ -2307,13 +2307,13 @@ public function testValidateAssociatedAtomicFalseDeepTrueWithErrors() {
$expected = array(
'Comment' => array(
'comment' => array(
0 => 'This field cannot be left blank',
0 => 'The provided value is invalid',
),
'User' => array(
'Comment' => array(
0 => array(
'comment' => array(
0 => 'This field cannot be left blank',
0 => 'The provided value is invalid',
),
),
),
Expand Down Expand Up @@ -2375,7 +2375,7 @@ public function testValidateManyAtomicFalseDeepTrueWithErrors() {
'Comment' => array(
0 => array(
'comment' => array(
0 => 'This field cannot be left blank',
0 => 'The provided value is invalid',
),
),
),
Expand Down

0 comments on commit 78c3e6a

Please sign in to comment.