Fix bug in size validation when using a string containing all numbers.

This commit is contained in:
Taylor Otwell 2011-08-08 10:35:28 -05:00
parent f470796261
commit 130772ca57
1 changed files with 5 additions and 2 deletions

View File

@ -250,7 +250,10 @@ protected function validate_max($attribute, $parameters)
*/ */
protected function get_size($attribute) protected function get_size($attribute)
{ {
if (is_numeric($this->attributes[$attribute])) return $this->attributes[$attribute]; if (is_numeric($this->attributes[$attribute]) and $this->has_rule($attribute, array('integer', 'numeric')))
{
return $this->attributes[$attribute];
}
return (array_key_exists($attribute, $_FILES)) ? $this->attributes[$attribute]['size'] / 1024 : Str::length(trim($this->attributes[$attribute])); return (array_key_exists($attribute, $_FILES)) ? $this->attributes[$attribute]['size'] / 1024 : Str::length(trim($this->attributes[$attribute]));
} }
@ -420,7 +423,7 @@ protected function get_message($attribute, $rule)
// For "size" rules that are validating strings or files, we need to adjust // For "size" rules that are validating strings or files, we need to adjust
// the default error message for the appropriate type. // the default error message for the appropriate type.
if (in_array($rule, $this->size_rules) and ! is_numeric($this->attributes[$attribute])) if (in_array($rule, $this->size_rules) and ! $this->has_rule($attribute, array('numeric', 'integer')))
{ {
return (array_key_exists($attribute, $_FILES)) return (array_key_exists($attribute, $_FILES))
? rtrim($message, '.').' '.Lang::line('validation.kilobytes')->get($this->language).'.' ? rtrim($message, '.').' '.Lang::line('validation.kilobytes')->get($this->language).'.'