Skip to content
Permalink
Browse files

Fixing doc blocks for CakeValidationRule and changing visibility for …

…some methods
  • Loading branch information...
lorenzo committed May 11, 2012
1 parent 34531d9 commit 2b7c2ad691ced1d0b51bdc7689aa1d8a78363f29
Showing with 21 additions and 13 deletions.
  1. +21 −13 lib/Cake/Model/Validator/CakeValidationRule.php
@@ -7,12 +7,12 @@
* PHP versions 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @package Cake.Model.Validator
* @since CakePHP(tm) v 2.2.0
@@ -23,36 +23,37 @@
App::uses('Validation', 'Utility');
/**
* CakeValidationRule object.
* CakeValidationRule object. Represents a validation method, error message and
* rules for applying such method to a field.
*
* @package Cake.Model.Validator
* @link http://book.cakephp.org/2.0/en/data-validation.html
*/
class CakeValidationRule {
/**
* The 'valid' value
* Whether the field passed this validation rule
*
* @var mixed
*/
protected $_valid = true;
/**
* Create or Update transaction?
* Holds whether the record being validated exists in datasource or not
*
* @var boolean
*/
protected $_recordExists = false;
/**
* The parsed rule
* Validation method
*
* @var mixed
*/
protected $_rule = null;
/**
* The parsed rule parameters
* Validation method arguments
*
* @var array
*/
@@ -130,7 +131,7 @@ public function isValid() {
}
/**
* Checks if the field is required by the 'required' value
* Checks if the field is required according to the `required` property
*
* @return boolean
*/
@@ -147,7 +148,7 @@ public function isRequired() {
}
/**
* Checks if the field failed the required validation
* Checks whether the field failed the `field should be present` validation
*
* @param array $data data to check rule against
* @return boolean
@@ -176,7 +177,7 @@ public function checkEmpty($field, &$data) {
}
/**
* Checks if the Validation rule can be skipped
* Checks if the validation rule should be skipped
*
* @return boolean True if the ValidationRule can be skipped
*/
@@ -190,7 +191,8 @@ public function skip() {
}
/**
* Checks if the 'last' key is true
* Returns whethere this rule should break validation process for associated field
* after it fails
*
* @return boolean
*/
@@ -212,7 +214,7 @@ public function getValidationResult() {
*
* @return array
*/
public function getPropertiesArray() {
protected function _getPropertiesArray() {
$rule = $this->rule;
if (!is_string($rule)) {
unset($rule[0]);
@@ -250,9 +252,10 @@ public function isUpdate($exists = null) {
* @return boolean True if the rule could be dispatched, false otherwise
*/
public function process($field, &$data, &$methods) {
$this->_valid = true;
$this->_parseRule($field, $data);
$validator = $this->getPropertiesArray();
$validator = $this->_getPropertiesArray();
$rule = strtolower($this->_rule);
if (isset($methods[$rule])) {
$this->_ruleParams[] = array_merge($validator, $this->_passedOptions);
@@ -270,6 +273,11 @@ public function process($field, &$data, &$methods) {
return true;
}
/**
* Returns passed options for this rule
*
* @return array
**/
public function getOptions($key) {
if (!isset($this->_passedOptions[$key])) {
return null;

0 comments on commit 2b7c2ad

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