Merge remote-tracking branch 'origin/validators-patch' into validators-patch

# Conflicts:
#	src/Valitron/Validator.php
This commit is contained in:
misantron 2017-10-26 23:11:06 +03:00
commit b0ddfb3a37
2 changed files with 6 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
.DS_Store
.idea/
composer.phar
composer.lock
vendor

View File

@ -944,7 +944,7 @@ class Validator
return array($values, true);
}
// Dead end, abort
elseif ($identifier === NULL || ! isset($data[$identifier])) {
elseif ($identifier === null || ! isset($data[$identifier])) {
if ($allow_empty){
//when empty values are allowed, we only care if the key exists
return array(null, array_key_exists($identifier, $data));
@ -1067,7 +1067,7 @@ class Validator
* instance only.
*
* @param string $name
* @param mixed $callback
* @param callable $callback
* @param string $message
* @throws \InvalidArgumentException
*/
@ -1083,14 +1083,13 @@ class Validator
* Register new validation rule callback
*
* @param string $name
* @param mixed $callback
* @param callable $callback
* @param string $message
* @throws \InvalidArgumentException
*/
public static function addRule($name, $callback, $message = null)
{
if ($message === null)
{
if ($message === null) {
$message = static::ERROR_DEFAULT;
}
@ -1159,7 +1158,7 @@ class Validator
$ruleMethod = 'validate' . ucfirst($rule);
if (!method_exists($this, $ruleMethod)) {
throw new \InvalidArgumentException(
"Rule '" . $rule . "' has not been registered with " . __CLASS__ . "::addRule()."
"Rule '" . $rule . "' has not been registered with " . get_called_class() . "::addRule()."
);
}
}