Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
cc08492b
Commit
cc08492b
authored
Mar 14, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #2729: Added `FilterValidator::skipOnArray` so that filters like `trim`…
Fixes #2729: Added `FilterValidator::skipOnArray` so that filters like `trim` will not fail for array inputs
parent
e5031dfd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
FilterValidator.php
framework/validators/FilterValidator.php
+9
-1
No files found.
framework/CHANGELOG.md
View file @
cc08492b
...
@@ -143,6 +143,7 @@ Yii Framework 2 Change Log
...
@@ -143,6 +143,7 @@ Yii Framework 2 Change Log
-
Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue)
-
Enh #2646: Added support for specifying hostinfo in the pattern of a URL rule (qiangxue)
-
Enh #2661: Added boolean column type support for SQLite (qiangxue)
-
Enh #2661: Added boolean column type support for SQLite (qiangxue)
-
Enh #2670: Changed
`console\Controller::globalOptions()`
to
`options($actionId)`
to (make it possible to) differentiate options per action (hqx)
-
Enh #2670: Changed
`console\Controller::globalOptions()`
to
`options($actionId)`
to (make it possible to) differentiate options per action (hqx)
-
Enh #2729: Added
`FilterValidator::skipOnArray`
so that filters like
`trim`
will not fail for array inputs (qiangxue)
-
Enh #2735: Added support for
`DateTimeInterface`
in
`Formatter`
(ivokund)
-
Enh #2735: Added support for
`DateTimeInterface`
in
`Formatter`
(ivokund)
-
Enh: Added support for using arrays as option values for console commands (qiangxue)
-
Enh: Added support for using arrays as option values for console commands (qiangxue)
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to default application templates (samdark)
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to default application templates (samdark)
...
...
framework/validators/FilterValidator.php
View file @
cc08492b
...
@@ -40,6 +40,11 @@ class FilterValidator extends Validator
...
@@ -40,6 +40,11 @@ class FilterValidator extends Validator
*/
*/
public
$filter
;
public
$filter
;
/**
/**
* @var boolean whether the filter should be skipped if an array input is given.
* If false and an array input is given, the filter will not be applied.
*/
public
$skipOnArray
=
false
;
/**
* @var boolean this property is overwritten to be false so that this validator will
* @var boolean this property is overwritten to be false so that this validator will
* be applied when the value being validated is empty.
* be applied when the value being validated is empty.
*/
*/
...
@@ -61,6 +66,9 @@ class FilterValidator extends Validator
...
@@ -61,6 +66,9 @@ class FilterValidator extends Validator
*/
*/
public
function
validateAttribute
(
$object
,
$attribute
)
public
function
validateAttribute
(
$object
,
$attribute
)
{
{
$object
->
$attribute
=
call_user_func
(
$this
->
filter
,
$object
->
$attribute
);
$value
=
$object
->
$attribute
;
if
(
$this
->
skipOnArray
||
!
is_array
(
$value
))
{
$object
->
$attribute
=
call_user_func
(
$this
->
filter
,
$value
);
}
}
}
}
}
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