Skip to content
Permalink
Browse files

Changed default validation error message to be rule neutral

  • Loading branch information...
bcrowe committed Aug 15, 2013
1 parent 7b407f8 commit 78c3e6a2de3dc95b08d2550926907e9eab748326
@@ -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;
@@ -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);
}
@@ -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/';
@@ -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);
@@ -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);
}
@@ -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);
@@ -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'));
@@ -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')
)
)
)
@@ -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')
)
)
)
@@ -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')
)
)
)
@@ -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')
)
)
)
@@ -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')
)
)
)
@@ -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')
)
)
);
@@ -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);
@@ -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);
@@ -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')
)
);
@@ -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'));
@@ -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);
@@ -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',
),
),
),
@@ -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',
),
),
),
Oops, something went wrong.

0 comments on commit 78c3e6a

Please sign in to comment.
You can’t perform that action at this time.