Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
eaa2cf59
Commit
eaa2cf59
authored
Feb 01, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for custom validation lines.
parent
a9873a47
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
19 deletions
+42
-19
validation.php
application/language/en/validation.php
+34
-17
validator.php
laravel/validator.php
+8
-2
No files found.
application/language/en/validation.php
View file @
eaa2cf59
...
...
@@ -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
laravel/validator.php
View file @
eaa2cf59
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment