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
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
validator.php
system/validator.php
+10
-3
No files found.
system/validator.php
View file @
f0db808f
...
@@ -38,12 +38,19 @@ class Validator {
...
@@ -38,12 +38,19 @@ class Validator {
public
$language
;
public
$language
;
/**
/**
* The
"size"
related validation rules.
* The
size
related validation rules.
*
*
* @var array
* @var array
*/
*/
protected
$size_rules
=
array
(
'size'
,
'between'
,
'min'
,
'max'
);
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.
* Create a new validator instance.
*
*
...
@@ -250,7 +257,7 @@ class Validator {
...
@@ -250,7 +257,7 @@ class Validator {
*/
*/
protected
function
get_size
(
$attribute
)
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
];
return
$this
->
attributes
[
$attribute
];
}
}
...
@@ -423,7 +430,7 @@ class Validator {
...
@@ -423,7 +430,7 @@ class Validator {
// For "size" rules that are validating strings or files, we need to adjust
// For "size" rules that are validating strings or files, we need to adjust
// the default error message for the appropriate type.
// 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
))
return
(
array_key_exists
(
$attribute
,
$_FILES
))
?
rtrim
(
$message
,
'.'
)
.
' '
.
Lang
::
line
(
'validation.kilobytes'
)
->
get
(
$this
->
language
)
.
'.'
?
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