Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding missing doc block for util\Validator::.

Fixing some coding standard violations.
  • Loading branch information...
commit 0c12c7868a208c3a349512d98380c2ac8e1ecbe9 1 parent 5fba2fb
@jperras jperras authored gwoo committed
Showing with 26 additions and 12 deletions.
  1. +26 −12 libraries/lithium/util/Validator.php
View
38 libraries/lithium/util/Validator.php
@@ -69,6 +69,13 @@ class Validator extends \lithium\core\StaticObject {
*/
protected static $_rules = array();
+ /**
+ * Default options used when defining a new validator rule.
+ *
+ * @var array Options
+ * @see lithium\util\Validator::add()
+ * @see lithium\util\Validator::rule()
+ */
protected static $_options = array(
'defaults' => array('contains' => true)
);
@@ -145,7 +152,9 @@ public static function __init() {
),
'ip' => function($value, $format = null, array $options = array()) {
$options += array('flags' => array());
- return (boolean) filter_var($value, FILTER_VALIDATE_IP, array('flags' => $options['flags']));
+ return (boolean) filter_var(
+ $value, FILTER_VALIDATE_IP, array('flags' => $options['flags'])
+ );
},
'money' => array(
'right' => '/^(?!0,?\d)(?:\d{1,3}(?:([, .])\d{3})?(?:\1\d{3})*|(?:\d+))' .
@@ -161,7 +170,9 @@ public static function __init() {
'(:[0-5]\d){0,2}$%',
'boolean' => function($value) {
$bool = is_bool($value);
- return ($bool || filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null);
+ $filter = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
+
+ return ($bool || $filter !== null);
},
'decimal' => function($value, $format = null, array $options = array()) {
if (isset($options['precision'])) {
@@ -224,7 +235,9 @@ public static function __init() {
},
'url' => function($value, $format = null, array $options = array()) {
$options += array('flags' => array());
- return (boolean) filter_var($value, FILTER_VALIDATE_URL, array('flags' => $options['flags']));
+ return (boolean) filter_var(
+ $value, FILTER_VALIDATE_URL, array('flags' => $options['flags'])
+ );
}
);
@@ -527,13 +540,13 @@ protected static function _checkFormats($rules) {
/**
* Validates credit card numbers. Returns true if `$value` is in the proper credit card format.
*
+ * @see lithium\util\Validator::isLuhn()
* @param mixed $value credit card number to validate
* @param mixed $type 'all' may be passed as a sting, defaults to fast which checks format of
* most major credit cards if an array is used only the values of the array
* are checked. Example: array('amex', 'bankcard', 'maestro')
* @param boolean $deep set to true this will check the Luhn algorithm of the credit card.
* @return boolean Success
- * @see lithium\util\Validator::isLuhn()
*/
// public static function isCreditCard($value, $format = 'fast', $deep = false) {}
@@ -663,16 +676,17 @@ protected static function _checkFormats($rules) {
// public static function isSsn($value, $format = null) {}
/**
- * Checks that a value is a valid URL according to http://www.w3.org/Addressing/URL/url-spec.txt
+ * Checks that a value is a valid URL according to
+ * http://www.w3.org/Addressing/URL/url-spec.txt
*
* The regex checks for the following component parts:
- * a valid, optional, scheme
- * a valid ip address OR
- * a valid domain name as defined by section 2.3.1 of http://www.ietf.org/rfc/rfc1035.txt
- * with an optional port number
- * an optional valid path
- * an optional query string (get parameters)
- * an optional fragment (anchor tag)
+ * - A valid, optional, scheme
+ * - A valid ip address OR
+ * - A valid domain name as defined by section 2.3.1 of
+ * http://www.ietf.org/rfc/rfc1035.txt with an optional port number
+ * - An optional valid path
+ * - An optional query string (get parameters)
+ * - An optional fragment (anchor tag)
*
* @param string $value Value to check
* @return boolean Success
Please sign in to comment.
Something went wrong with that request. Please try again.