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
9e46cada
Commit
9e46cada
authored
Nov 29, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactoring of the Validator. Mainly code formatting and naming changes.
parent
ed092bf6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
8 deletions
+19
-8
validator.php
laravel/validator.php
+19
-8
No files found.
laravel/validator.php
View file @
9e46cada
...
...
@@ -38,7 +38,7 @@ class Validator {
*
* @var Database\Connection
*/
protected
$
connection
;
protected
$
db
;
/**
* The language that should be used when retrieving error messages.
...
...
@@ -160,9 +160,9 @@ class Validator {
$value
=
Arr
::
get
(
$this
->
attributes
,
$attribute
);
if
(
!
$this
->
validatable
(
$rule
,
$attribute
,
$value
))
return
;
$validatable
=
$this
->
validatable
(
$rule
,
$attribute
,
$value
)
;
if
(
!
$this
->
{
'validate_'
.
$rule
}(
$attribute
,
$value
,
$parameters
,
$this
))
if
(
$validatable
and
!
$this
->
{
'validate_'
.
$rule
}(
$attribute
,
$value
,
$parameters
,
$this
))
{
$this
->
error
(
$attribute
,
$rule
,
$parameters
);
}
...
...
@@ -182,7 +182,18 @@ class Validator {
*/
protected
function
validatable
(
$rule
,
$attribute
,
$value
)
{
return
(
$this
->
validate_required
(
$attribute
,
$value
)
or
in_array
(
$rule
,
array
(
'required'
,
'accepted'
)));
return
$this
->
validate_required
(
$attribute
,
$value
)
or
$this
->
implicit
(
$rule
);
}
/**
* Determine if a given rule implies that the attribute is required.
*
* @param string $rule
* @return bool
*/
protected
function
implicit
(
$rule
)
{
return
$rule
==
'required'
or
$rule
==
'accepted'
;
}
/**
...
...
@@ -401,9 +412,9 @@ class Validator {
{
if
(
!
isset
(
$parameters
[
1
]))
$parameters
[
1
]
=
$attribute
;
if
(
is_null
(
$this
->
connection
))
$this
->
connection
=
DB
::
connection
();
if
(
is_null
(
$this
->
db
))
$this
->
db
=
DB
::
connection
();
return
$this
->
connection
->
table
(
$parameters
[
0
])
->
where
(
$parameters
[
1
],
'='
,
$value
)
->
count
()
==
0
;
return
$this
->
db
->
table
(
$parameters
[
0
])
->
where
(
$parameters
[
1
],
'='
,
$value
)
->
count
()
==
0
;
}
/**
...
...
@@ -678,7 +689,7 @@ class Validator {
*/
public
function
connection
(
\Laravel\Database\Connection
$connection
)
{
$this
->
connection
=
$connection
;
$this
->
db
=
$connection
;
return
$this
;
}
...
...
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