added support for custom validation lines.
This commit is contained in:
parent
a9873a479d
commit
eaa2cf593c
|
@ -2,23 +2,6 @@
|
|||
|
||||
return array(
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Attribute Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". Your users will thank you.
|
||||
|
|
||||
| The Validator class will automatically search this array of lines it
|
||||
| is attempting to replace the :attribute place-holder in messages.
|
||||
| It's pretty slick. We think you'll like it.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => array(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Language Lines
|
||||
|
@ -74,4 +57,38 @@
|
|||
"unique" => "The :attribute has already been taken.",
|
||||
"url" => "The :attribute format is invalid.",
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Custom Validation Language Lines
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify custom validation messages for attributes using the
|
||||
| convention "attribute_rule" to name the lines. This helps keep your
|
||||
| custom validation clean and tidy.
|
||||
|
|
||||
| So, say you want to use a custom validation message when validating that
|
||||
| the "email" attribute is unique. Just add "email_unique" to this array
|
||||
| with your custom message. The Validator will handle the rest!
|
||||
|
|
||||
*/
|
||||
|
||||
'custom' => array(),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Validation Attributes
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The following language lines are used to swap attribute place-holders
|
||||
| with something more reader friendly such as "E-Mail Address" instead
|
||||
| of "email". Your users will thank you.
|
||||
|
|
||||
| The Validator class will automatically search this array of lines it
|
||||
| is attempting to replace the :attribute place-holder in messages.
|
||||
| It's pretty slick. We think you'll like it.
|
||||
|
|
||||
*/
|
||||
|
||||
'attributes' => array(),
|
||||
|
||||
);
|
|
@ -604,9 +604,15 @@ protected function message($attribute, $rule)
|
|||
// First we'll check for developer specified, attribute specific messages.
|
||||
// These messages take first priority. They allow the fine-grained tuning
|
||||
// of error messages for each rule.
|
||||
if (array_key_exists($attribute.'_'.$rule, $this->messages))
|
||||
$custom = $attribute.'_'.$rule;
|
||||
|
||||
if (array_key_exists($custom, $this->messages))
|
||||
{
|
||||
return $this->messages[$attribute.'_'.$rule];
|
||||
return $this->messages[$custom];
|
||||
}
|
||||
elseif (Lang::has($custom = "validation.custom.{$custom}", $this->language))
|
||||
{
|
||||
return Lang::line($custom)->get($this->language);
|
||||
}
|
||||
|
||||
// Next we'll check for developer specified, rule specific error messages.
|
||||
|
|
Loading…
Reference in New Issue