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
430eeb6d
Commit
430eeb6d
authored
Jul 07, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #798 from xsbeats/feature/validation_required_with
Added required_with validation rule...
parents
990f10f6
6881bdaf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
validation.md
laravel/documentation/validation.md
+3
-0
validator.php
laravel/validator.php
+22
-1
No files found.
laravel/documentation/validation.md
View file @
430eeb6d
...
...
@@ -63,6 +63,9 @@ Now you are familiar with the basic usage of the Validator class. You're ready t
'name' => 'required'
#### Validate that an attribute is present, when another attribute is present:
'last_name' => 'required_with:first_name'
<a
name=
"rule-alpha"
></a>
### Alpha, Alpha Numeric, & Alpha Dash
...
...
laravel/validator.php
View file @
430eeb6d
...
...
@@ -214,7 +214,7 @@ class Validator {
*/
protected
function
implicit
(
$rule
)
{
return
$rule
==
'required'
or
$rule
==
'accepted'
;
return
$rule
==
'required'
or
$rule
==
'accepted'
or
$rule
==
'required_with'
;
}
/**
...
...
@@ -257,6 +257,27 @@ class Validator {
return
true
;
}
/**
* Validate that an attribute exists in the attributes array, if another
* attribute exists in the attributes array.
*
* @param string $attribute
* @param mixed $value
* @param array $parameters
* @return bool
*/
protected
function
validate_required_with
(
$attribute
,
$value
,
$parameters
)
{
$other
=
$parameters
[
0
];
if
(
$this
->
validate_required
(
$other
,
$this
->
attributes
[
$other
]))
{
return
$this
->
validate_required
(
$attribute
,
$value
);
}
return
true
;
}
/**
* Validate that an attribute has a matching confirmation attribute.
*
...
...
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