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
6f366d30
Commit
6f366d30
authored
Oct 16, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
continuing to refactor the validator.
parent
ca784e9f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
20 deletions
+23
-20
laravel/validation/validator.php
+23
-20
No files found.
laravel/validation/validator.php
View file @
6f366d30
...
...
@@ -139,10 +139,7 @@ class Validator {
foreach
(
$this
->
rules
as
$attribute
=>
$rules
)
{
foreach
(
$rules
as
$rule
)
{
$this
->
check
(
$attribute
,
$rule
);
}
foreach
(
$rules
as
$rule
)
$this
->
check
(
$attribute
,
$rule
);
}
return
count
(
$this
->
errors
->
messages
)
==
0
;
...
...
@@ -159,27 +156,33 @@ class Validator {
{
list
(
$rule
,
$parameters
)
=
$this
->
parse
(
$rule
);
if
(
!
method_exists
(
$this
,
$validator
=
'validate_'
.
$rule
)
and
!
isset
(
static
::
$validators
[
$rule
]))
{
throw
new
\Exception
(
"Validation rule [
$rule
] doesn't exist."
);
}
// Extract the actual value for the attribute. We don't want every rule
// to worry about obtaining the value from the array of attributes.
$value
=
Arr
::
get
(
$this
->
attributes
,
$attribute
);
// Verify that the attribute and rule combination is actually validatable before
// attempting to call the validation rule. Unless the rule implicitly requires
// the attribute to exist, we will not call any rules for attributes that are
// not in the validator's attribute array.
if
(
!
$this
->
validatable
(
$rule
,
$attribute
,
$value
=
Arr
::
get
(
$this
->
attributes
,
$attribute
)))
return
;
// No validation will be run for attributes that do not exist unless the
// rule being validated is "required" or "accepted". No other rules have
// implicit "required" checks for validation.
if
(
!
$this
->
validate_required
(
$attribute
,
$value
)
and
!
in_array
(
$rule
,
array
(
'required'
,
'accepted'
)))
if
(
!
$this
->
{
'validate_'
.
$rule
}(
$attribute
,
$value
,
$parameters
,
$this
))
{
return
;
$this
->
error
(
$attribute
,
$rule
,
$parameters
);
}
}
if
(
!
$this
->
$validator
(
$attribute
,
$value
,
$parameters
,
$this
))
/**
* Determine if an attribute is validatable.
*
* To be considered validatable, the attribute must either exist, or the rule being
* checked must implicitly validate "required", such as the "required" rule or the
* "accepted" rule. No other rules have implicit "required" validation.
*
* @param string $rule
* @param string $attribute
* @param mixed $value
* @return bool
*/
protected
function
validatable
(
$rule
,
$attribute
,
$value
)
{
$this
->
error
(
$attribute
,
$rule
,
$parameters
);
}
return
(
$this
->
validate_required
(
$attribute
,
$value
)
or
in_array
(
$rule
,
array
(
'required'
,
'accepted'
)));
}
/**
...
...
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