Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Renaming CakeField to CakeValidationSet

  • Loading branch information...
commit b6c8a345e7cf6b40aa3dcc7a4015d505209b3bb7 1 parent 843d95b
@lorenzo lorenzo authored
View
17 lib/Cake/Model/ModelValidator.php
@@ -18,7 +18,7 @@
* @since CakePHP(tm) v 2.2.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::uses('CakeField', 'Model/Validator');
+App::uses('CakeValidationSet', 'Model/Validator');
App::uses('CakeRule', 'Model/Validator');
/**
@@ -30,14 +30,7 @@
class ModelValidator {
/**
- * Holds the validationErrors
- *
- * @var array
- */
- public $validationErrors = array();
-
-/**
- * Holds the CakeField objects array
+ * Holds the CakeValidationSet objects array
*
* @var array
*/
@@ -279,7 +272,7 @@ public function getMethods() {
* Gets all fields if $name is null (default), or the field for fieldname $name if it's found.
*
* @param string $name [optional] The fieldname to fetch. Defaults to null.
- * @return mixed Either array of CakeField objects , single object for $name or false when $name not present in fields
+ * @return mixed Either array of CakeValidationSet objects , single object for $name or false when $name not present in fields
*/
public function getFields($name = null) {
if ($name !== null && !empty($this->_fields[$name])) {
@@ -291,7 +284,7 @@ public function getFields($name = null) {
}
/**
- * Sets the CakeField instances from the Model::$validate property after processing the fieldList and whiteList.
+ * Sets the CakeValidationSet instances from the Model::$validate property after processing the fieldList and whiteList.
* If Model::$validate is not set or empty, this method returns false. True otherwise.
*
* @return boolean True if Model::$validate was processed, false otherwise
@@ -311,7 +304,7 @@ protected function _parseRules() {
$this->_fields = array();
$methods = $this->getMethods();
foreach ($this->_validate as $fieldName => $ruleSet) {
- $this->_fields[$fieldName] = new CakeField($fieldName, $ruleSet, $methods);
+ $this->_fields[$fieldName] = new CakeValidationSet($fieldName, $ruleSet, $methods);
}
return true;
}
View
2  lib/Cake/Model/Validator/CakeRule.php
@@ -19,7 +19,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::uses('ModelValidator', 'Model');
-App::uses('CakeField', 'Model/Validator');
+App::uses('CakeValidationSet', 'Model/Validator');
App::uses('Validation', 'Utility');
/**
View
4 lib/Cake/Model/Validator/CakeField.php → ...ake/Model/Validator/CakeValidationSet.php
@@ -22,12 +22,12 @@
App::uses('CakeRule', 'Model/Validator');
/**
- * CakeField object.
+ * CakeValidationSet object.
*
* @package Cake.Model.Validator
* @link http://book.cakephp.org/2.0/en/data-validation.html
*/
-class CakeField {
+class CakeValidationSet {
/**
* Holds the ValidationRule objects
View
2  lib/Cake/Test/Case/Model/ModelTest.php
@@ -34,7 +34,7 @@ class ModelTest extends PHPUnit_Framework_TestSuite {
public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('All Model related class tests');
- $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeFieldTest.php');
+ $suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeValidationSetTest.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'Validator' . DS .'CakeRuleTest.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelReadTest.php');
$suite->addTestFile(CORE_TEST_CASES . DS . 'Model' . DS . 'ModelWriteTest.php');
View
22 ...st/Case/Model/Validator/CakeFieldTest.php → ...Model/Validator/CakeValidationSetTest.php
@@ -1,6 +1,6 @@
<?php
/**
- * CakeFieldTest file
+ * CakeValidationSetTest file
*
* PHP 5
*
@@ -17,14 +17,14 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
-App::uses('CakeField', 'Model/Validator');
+App::uses('CakeValidationSet', 'Model/Validator');
/**
- * CakeFieldTest
+ * CakeValidationSetTest
*
* @package Cake.Test.Case.Model.Validator
*/
-class CakeFieldTest extends CakeTestModel {
+class CakeValidationSetTest extends CakeTestModel {
/**
* setUp method
@@ -41,7 +41,7 @@ public function setUp() {
* @return void
*/
public function testValidate() {
- $Field = new CakeField('title', 'notEmpty');
+ $Field = new CakeValidationSet('title', 'notEmpty');
$data = array(
'title' => '',
'body' => 'a body'
@@ -51,12 +51,12 @@ public function testValidate() {
$expected = array('This field cannot be left blank');
$this->assertEquals($expected, $result);
- $Field = new CakeField('body', 'notEmpty');
+ $Field = new CakeValidationSet('body', 'notEmpty');
$result = $Field->validate($data);
$this->assertEmpty($result);
- $Field = new CakeField('nothere', array('notEmpty' => array('rule' => 'notEmpty', 'required' => true)));
+ $Field = new CakeValidationSet('nothere', array('notEmpty' => array('rule' => 'notEmpty', 'required' => true)));
$result = $Field->validate($data);
$expected = array('notEmpty');
@@ -70,7 +70,7 @@ public function testValidate() {
*/
public function testGetRule() {
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
- $Field = new CakeField('title', $rules);
+ $Field = new CakeValidationSet('title', $rules);
$data = array(
'title' => '',
'body' => 'a body'
@@ -93,7 +93,7 @@ public function testGetRule() {
*/
public function testGetRules() {
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
- $Field = new CakeField('title', $rules);
+ $Field = new CakeValidationSet('title', $rules);
$result = $Field->getRules();
$this->assertEquals(array('notEmpty'), array_keys($result));
@@ -107,7 +107,7 @@ public function testGetRules() {
*/
public function testSetRule() {
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
- $Field = new CakeField('title', $rules);
+ $Field = new CakeValidationSet('title', $rules);
$Rule = new CakeRule('notEmpty', $rules['notEmpty']);
$this->assertEquals($Rule, $Field->getRule('notEmpty'));
@@ -140,7 +140,7 @@ public function testSetRule() {
*/
public function testSetRules() {
$rule = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
- $Field = new CakeField('title', $rule);
+ $Field = new CakeValidationSet('title', $rule);
$RuleEmpty = new CakeRule('title', $rule['notEmpty'], 'notEmpty');
$rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));
Please sign in to comment.
Something went wrong with that request. Please try again.