mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-31 07:01:54 +00:00
Merge remote-tracking branch 'origin/validators-patch' into validators-patch
# Conflicts: # src/Valitron/Validator.php
This commit is contained in:
commit
b0ddfb3a37
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea/
|
||||||
composer.phar
|
composer.phar
|
||||||
composer.lock
|
composer.lock
|
||||||
vendor
|
vendor
|
||||||
|
|||||||
@ -944,7 +944,7 @@ class Validator
|
|||||||
return array($values, true);
|
return array($values, true);
|
||||||
}
|
}
|
||||||
// Dead end, abort
|
// Dead end, abort
|
||||||
elseif ($identifier === NULL || ! isset($data[$identifier])) {
|
elseif ($identifier === null || ! isset($data[$identifier])) {
|
||||||
if ($allow_empty){
|
if ($allow_empty){
|
||||||
//when empty values are allowed, we only care if the key exists
|
//when empty values are allowed, we only care if the key exists
|
||||||
return array(null, array_key_exists($identifier, $data));
|
return array(null, array_key_exists($identifier, $data));
|
||||||
@ -1067,7 +1067,7 @@ class Validator
|
|||||||
* instance only.
|
* instance only.
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param mixed $callback
|
* @param callable $callback
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
@ -1083,14 +1083,13 @@ class Validator
|
|||||||
* Register new validation rule callback
|
* Register new validation rule callback
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param mixed $callback
|
* @param callable $callback
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function addRule($name, $callback, $message = null)
|
public static function addRule($name, $callback, $message = null)
|
||||||
{
|
{
|
||||||
if ($message === null)
|
if ($message === null) {
|
||||||
{
|
|
||||||
$message = static::ERROR_DEFAULT;
|
$message = static::ERROR_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1159,7 +1158,7 @@ class Validator
|
|||||||
$ruleMethod = 'validate' . ucfirst($rule);
|
$ruleMethod = 'validate' . ucfirst($rule);
|
||||||
if (!method_exists($this, $ruleMethod)) {
|
if (!method_exists($this, $ruleMethod)) {
|
||||||
throw new \InvalidArgumentException(
|
throw new \InvalidArgumentException(
|
||||||
"Rule '" . $rule . "' has not been registered with " . __CLASS__ . "::addRule()."
|
"Rule '" . $rule . "' has not been registered with " . get_called_class() . "::addRule()."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user