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
8bd6d346
Commit
8bd6d346
authored
Oct 16, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring validator.
parent
48f1879b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
validator.php
laravel/validation/validator.php
+13
-13
No files found.
laravel/validation/validator.php
View file @
8bd6d346
<?php
namespace
Laravel\Validation
;
<?php
namespace
Laravel\Validation
;
use
Closure
;
use
Closure
;
use
Laravel\Arr
;
use
Laravel\IoC
;
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Str
;
use
Laravel\Lang
;
use
Laravel\Lang
;
...
@@ -52,25 +53,25 @@ class Validator {
...
@@ -52,25 +53,25 @@ class Validator {
protected
$language
;
protected
$language
;
/**
/**
* The
registered custom validator
s.
* The
size related validation rule
s.
*
*
* @var array
* @var array
*/
*/
protected
static
$validators
=
array
(
);
protected
$size_rules
=
array
(
'size'
,
'between'
,
'min'
,
'max'
);
/**
/**
* The
size
related validation rules.
* The
numeric
related validation rules.
*
*
* @var array
* @var array
*/
*/
protected
$
size_rules
=
array
(
'size'
,
'between'
,
'min'
,
'max
'
);
protected
$
numeric_rules
=
array
(
'numeric'
,
'integer
'
);
/**
/**
* The
numeric related validation rule
s.
* The
registered custom validator
s.
*
*
* @var array
* @var array
*/
*/
protected
$numeric_rules
=
array
(
'numeric'
,
'integer'
);
protected
static
$validators
=
array
(
);
/**
/**
* Create a new validator instance.
* Create a new validator instance.
...
@@ -165,12 +166,15 @@ class Validator {
...
@@ -165,12 +166,15 @@ class Validator {
// Extract the actual value for the attribute. We don't want every rule
// Extract the actual value for the attribute. We don't want every rule
// to worry about obtaining the value from the array of attributes.
// to worry about obtaining the value from the array of attributes.
$value
=
(
isset
(
$this
->
attributes
[
$attribute
]))
?
$this
->
attributes
[
$attribute
]
:
null
;
$value
=
Arr
::
get
(
$this
->
attributes
,
$attribute
)
;
// No validation will be run for attributes that do not exist unless the
// No validation will be run for attributes that do not exist unless the
// rule being validated is "required" or "accepted". No other rules have
// rule being validated is "required" or "accepted". No other rules have
// implicit "required" checks for validation.
// implicit "required" checks for validation.
if
(
!
$this
->
validate_required
(
$attribute
)
and
!
in_array
(
$rule
,
array
(
'required'
,
'accepted'
)))
return
;
if
(
!
$this
->
validate_required
(
$attribute
,
$value
)
and
!
in_array
(
$rule
,
array
(
'required'
,
'accepted'
)))
{
return
;
}
if
(
!
$this
->
$validator
(
$attribute
,
$value
,
$parameters
,
$this
))
if
(
!
$this
->
$validator
(
$attribute
,
$value
,
$parameters
,
$this
))
{
{
...
@@ -204,11 +208,7 @@ class Validator {
...
@@ -204,11 +208,7 @@ class Validator {
*/
*/
protected
function
validate_required
(
$attribute
,
$value
)
protected
function
validate_required
(
$attribute
,
$value
)
{
{
if
(
is_null
(
$value
))
return
false
;
return
(
is_null
(
$value
)
or
(
is_string
(
$value
)
and
trim
(
$value
)
===
''
));
if
(
is_string
(
$value
)
and
trim
(
$value
)
===
''
)
return
false
;
return
true
;
}
}
/**
/**
...
...
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