refactor the validate required method for clarity.

This commit is contained in:
Taylor Otwell 2011-11-27 13:50:50 -06:00
parent d93301672d
commit dae283943f
1 changed files with 14 additions and 1 deletions

View File

@ -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;
}
/**