refactor the validate required method for clarity.
This commit is contained in:
parent
d93301672d
commit
dae283943f
|
@ -211,7 +211,20 @@ protected function error($attribute, $rule, $parameters)
|
|||
*/
|
||||
protected function validate_required($attribute, $value)
|
||||
{
|
||||
return ! (is_null($value) or (is_string($value) and trim($value) === ''));
|
||||
if (is_null($value))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif (is_string($value) and trim($value) === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif (is_array($value) and count($value) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue