|
|
@@ -36,7 +36,7 @@ class ValidationSet implements ArrayAccess, IteratorAggregate, Countable
|
|
|
/**
|
|
|
* Denotes whether the fieldname key must be present in data array
|
|
|
*
|
|
|
- * @var bool|string
|
|
|
+ * @var bool|string|callable
|
|
|
*/
|
|
|
protected $_validatePresent = false;
|
|
|
|
|
|
@@ -52,7 +52,8 @@ class ValidationSet implements ArrayAccess, IteratorAggregate, Countable
|
|
|
*
|
|
|
* If no argument is passed the currently set `validatePresent` value will be returned.
|
|
|
*
|
|
|
- * @param bool|string|null $validatePresent Valid values are true, false, 'create', 'update'
|
|
|
+ * @param bool|string|callable|null $validatePresent Deprecated since 3.6.0 ValidationSet::isPresenceRequired() is deprecated as a setter
|
|
|
+ * Use ValidationSet::requirePresence() instead.
|
|
|
* @return bool|string
|
|
|
*/
|
|
|
public function isPresenceRequired($validatePresent = null)
|
|
|
@@ -61,16 +62,34 @@ class ValidationSet implements ArrayAccess, IteratorAggregate, Countable
|
|
|
return $this->_validatePresent;
|
|
|
}
|
|
|
|
|
|
- return $this->_validatePresent = $validatePresent;
|
|
|
+ deprecationWarning(
|
|
|
+ 'ValidationSet::isPresenceRequired() is deprecated as a setter. ' .
|
|
|
+ 'Use ValidationSet::requirePresence() instead.'
|
|
|
+ );
|
|
|
+
|
|
|
+ return $this->requirePresence($validatePresent);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets whether a field is required to be present in data array.
|
|
|
+ *
|
|
|
+ * @param bool|string|callable $validatePresent Valid values are true, false, 'create', 'update' or a callable.
|
|
|
+ * @return $this
|
|
|
+ */
|
|
|
+ public function requirePresence($validatePresent)
|
|
|
+ {
|
|
|
+ $this->_validatePresent = $validatePresent;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Sets whether a field value is allowed to be empty
|
|
|
+ * Sets whether a field value is allowed to be empty.
|
|
|
*
|
|
|
* If no argument is passed the currently set `allowEmpty` value will be returned.
|
|
|
*
|
|
|
- * @param bool|string|callable|null $allowEmpty Valid values are true, false,
|
|
|
- * 'create', 'update'
|
|
|
+ * @param bool|string|callable|null $allowEmpty Deprecated since 3.6.0 ValidationSet::isEmptyAllowed() is deprecated as a setter.
|
|
|
+ * Use ValidationSet::allowEmpty() instead.
|
|
|
* @return bool|string|callable
|
|
|
*/
|
|
|
public function isEmptyAllowed($allowEmpty = null)
|
|
|
@@ -79,14 +98,33 @@ class ValidationSet implements ArrayAccess, IteratorAggregate, Countable
|
|
|
return $this->_allowEmpty;
|
|
|
}
|
|
|
|
|
|
- return $this->_allowEmpty = $allowEmpty;
|
|
|
+ deprecationWarning(
|
|
|
+ 'ValidationSet::isEmptyAllowed() is deprecated as a setter. ' .
|
|
|
+ 'Use ValidationSet::allowEmpty() instead.'
|
|
|
+ );
|
|
|
+
|
|
|
+ return $this->allowEmpty($allowEmpty);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets whether a field value is allowed to be empty.
|
|
|
+ *
|
|
|
+ * @param bool|string|callable $allowEmpty Valid values are true, false,
|
|
|
+ * 'create', 'update' or a callable.
|
|
|
+ * @return $this
|
|
|
+ */
|
|
|
+ public function allowEmpty($allowEmpty)
|
|
|
+ {
|
|
|
+ $this->_allowEmpty = $allowEmpty;
|
|
|
+
|
|
|
+ return $this;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Gets a rule for a given name if exists
|
|
|
*
|
|
|
* @param string $name The name under which the rule is set.
|
|
|
- * @return \Cake\Validation\ValidationRule
|
|
|
+ * @return \Cake\Validation\ValidationRule|null
|
|
|
*/
|
|
|
public function rule($name)
|
|
|
{
|