Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
19cd5395
Commit
19cd5395
authored
Dec 19, 2012
by
Jason Walton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added validation message to language file for required_with
Signed-off-by: Jason Walton <jwalton512@gmail.com>
parent
8ff052cb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
0 deletions
+36
-0
application/language/en/validation.php
+1
-0
laravel/tests/application/language/en/validation.php
+1
-0
laravel/tests/cases/validator.test.php
+20
-0
laravel/validator.php
+14
-0
No files found.
application/language/en/validation.php
View file @
19cd5395
...
...
@@ -58,6 +58,7 @@ return array(
"not_in"
=>
"The selected :attribute is invalid."
,
"numeric"
=>
"The :attribute must be a number."
,
"required"
=>
"The :attribute field is required."
,
"required_with"
=>
"The :attribute field is required with :field"
,
"same"
=>
"The :attribute and :other must match."
,
"size"
=>
array
(
"numeric"
=>
"The :attribute must be :size."
,
...
...
laravel/tests/application/language/en/validation.php
View file @
19cd5395
...
...
@@ -50,6 +50,7 @@ return array(
"not_in"
=>
"The selected :attribute is invalid."
,
"numeric"
=>
"The :attribute must be a number."
,
"required"
=>
"The :attribute field is required."
,
"required_with"
=>
"The :attribute field is required with :field"
,
"same"
=>
"The :attribute and :other must match."
,
"size"
=>
array
(
"numeric"
=>
"The :attribute must be :size."
,
...
...
laravel/tests/cases/validator.test.php
View file @
19cd5395
...
...
@@ -666,4 +666,24 @@ class ValidatorTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
$expect
,
$v
->
errors
->
first
(
'test_attribute'
));
}
/**
* Test required_with attribute names are replaced.
*
* @group laravel
*/
public
function
testRequiredWithAttributesAreReplaced
()
{
$lang
=
require
path
(
'app'
)
.
'language/en/validation.php'
;
$data
=
array
(
'first_name'
=>
'Taylor'
,
'last_name'
=>
''
);
$rules
=
array
(
'first_name'
=>
'required'
,
'last_name'
=>
'required_with:first_name'
);
$v
=
Validator
::
make
(
$data
,
$rules
);
$v
->
valid
();
$expect
=
str_replace
(
array
(
':attribute'
,
':field'
),
array
(
'last name'
,
'first name'
),
$lang
[
'required_with'
]);
$this
->
assertEquals
(
$expect
,
$v
->
errors
->
first
(
'last_name'
));
}
}
laravel/validator.php
View file @
19cd5395
...
...
@@ -864,6 +864,20 @@ class Validator {
}
/**
* Replace all place-holders for the required_with rule.
*
* @param string $message
* @param string $attribute
* @param string $rule
* @param array $parameters
* @return string
*/
protected
function
replace_required_with
(
$message
,
$attribute
,
$rule
,
$parameters
)
{
return
str_replace
(
':field'
,
$this
->
attribute
(
$parameters
[
0
]),
$message
);
}
/**
* Replace all place-holders for the between rule.
*
* @param string $message
...
...
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