Commit fc820e73 by Taylor Otwell

continuing to refactor the validator.

parent 4f560fdf
...@@ -496,10 +496,9 @@ class Validator { ...@@ -496,10 +496,9 @@ class Validator {
* Get the proper error message for an attribute and rule. * Get the proper error message for an attribute and rule.
* *
* Developer specified attribute specific rules take first priority. * Developer specified attribute specific rules take first priority.
* Developer specified error rules take second priority. * Developer specified error rules take second priority. If the error
* * message has not been specified by the developer, the default will
* If the message has not been specified by the developer, the default * be used from the validation language file.
* will be used from the validation language file.
* *
* @param string $attribute * @param string $attribute
* @param string $rule * @param string $rule
...@@ -507,14 +506,21 @@ class Validator { ...@@ -507,14 +506,21 @@ class Validator {
*/ */
protected function message($attribute, $rule) protected function message($attribute, $rule)
{ {
// First we'll check for developer specified, attribute specific messages. These messages
// take first priority if they have been specified. They allow the fine-grained tuning
// of error messages for each rule.
if (array_key_exists($attribute.'_'.$rule, $this->messages)) if (array_key_exists($attribute.'_'.$rule, $this->messages))
{ {
return $this->messages[$attribute.'_'.$rule]; return $this->messages[$attribute.'_'.$rule];
} }
// Next we'll check for developer specified, rule specific messages. These allow the
// developer to override the error message for an entire rule, regardless of the
// attribute being validated by that rule.
elseif (array_key_exists($rule, $this->messages)) elseif (array_key_exists($rule, $this->messages))
{ {
return $this->messages[$rule]; return $this->messages[$rule];
} }
// If the
elseif (in_array($rule, $this->size_rules) and ! $this->has_rule($attribute, $this->numeric_rules)) elseif (in_array($rule, $this->size_rules) and ! $this->has_rule($attribute, $this->numeric_rules))
{ {
$line = (array_key_exists($attribute, Input::file())) ? "file" : "string"; $line = (array_key_exists($attribute, Input::file())) ? "file" : "string";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment