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
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
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
4 deletions
+40
-4
validation.php
application/language/en/validation.php
+2
-1
validation.php
laravel/tests/application/language/en/validation.php
+2
-1
validator.test.php
laravel/tests/cases/validator.test.php
+21
-1
validator.php
laravel/validator.php
+15
-1
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
...
...
@@ -863,6 +863,20 @@ class Validator {
return
$message
;
}
/**
* 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.
*
...
...
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