Commit eaa2cf59 authored by Taylor Otwell's avatar Taylor Otwell

added support for custom validation lines.

parent a9873a47
......@@ -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 @@ return array(
"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(),
);
\ No newline at end of file
......@@ -604,9 +604,15 @@ class Validator {
// 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[$custom];
}
elseif (Lang::has($custom = "validation.custom.{$custom}", $this->language))
{
return $this->messages[$attribute.'_'.$rule];
return Lang::line($custom)->get($this->language);
}
// Next we'll check for developer specified, rule specific error messages.
......
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