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
f0db808f
Commit
f0db808f
authored
Aug 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor the validator class.
parent
3d48b323
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
system/validator.php
+10
-3
No files found.
system/validator.php
View file @
f0db808f
...
...
@@ -38,13 +38,20 @@ class Validator {
public
$language
;
/**
* The
"size"
related validation rules.
* The
size
related validation rules.
*
* @var array
*/
protected
$size_rules
=
array
(
'size'
,
'between'
,
'min'
,
'max'
);
/**
* The numeric related validation rules.
*
* @var array
*/
protected
$numeric_rules
=
array
(
'numeric'
,
'integer'
);
/**
* Create a new validator instance.
*
* @param array $attributes
...
...
@@ -250,7 +257,7 @@ class Validator {
*/
protected
function
get_size
(
$attribute
)
{
if
(
is_numeric
(
$this
->
attributes
[
$attribute
])
and
$this
->
has_rule
(
$attribute
,
array
(
'integer'
,
'numeric'
)
))
if
(
is_numeric
(
$this
->
attributes
[
$attribute
])
and
$this
->
has_rule
(
$attribute
,
$this
->
numeric_rules
))
{
return
$this
->
attributes
[
$attribute
];
}
...
...
@@ -423,7 +430,7 @@ class Validator {
// For "size" rules that are validating strings or files, we need to adjust
// the default error message for the appropriate type.
if
(
in_array
(
$rule
,
$this
->
size_rules
)
and
!
$this
->
has_rule
(
$attribute
,
array
(
'numeric'
,
'integer'
)
))
if
(
in_array
(
$rule
,
$this
->
size_rules
)
and
!
$this
->
has_rule
(
$attribute
,
$this
->
numeric_rules
))
{
return
(
array_key_exists
(
$attribute
,
$_FILES
))
?
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.kilobytes'
)
->
get
(
$this
->
language
)
.
'.'
...
...
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