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
5b0886f1
Commit
5b0886f1
authored
Nov 13, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow "on" and "attributes" to take either array or string for validators.
parent
447bad5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
Validator.php
framework/yii/validators/Validator.php
+19
-3
No files found.
framework/yii/validators/Validator.php
View file @
5b0886f1
...
...
@@ -76,7 +76,8 @@ abstract class Validator extends Component
];
/**
* @var array list of attributes to be validated.
* @var array|string attributes to be validated by this validator. For multiple attributes,
* please specify them as an array; for single attribute, you may use either a string or an array.
*/
public
$attributes
=
[];
/**
...
...
@@ -88,7 +89,8 @@ abstract class Validator extends Component
*/
public
$message
;
/**
* @var array list of scenarios that the validator can be applied to.
* @var array|string scenarios that the validator can be applied to. For multiple scenarios,
* please specify them as an array; for single scenario, you may use either a string or an array.
*/
public
$on
=
[];
/**
...
...
@@ -131,7 +133,7 @@ abstract class Validator extends Component
* @param array $params initial values to be applied to the validator properties
* @return Validator the validator
*/
public
static
function
createValidator
(
$type
,
$object
,
array
$attributes
,
$params
=
[])
public
static
function
createValidator
(
$type
,
$object
,
$attributes
,
$params
=
[])
{
$params
[
'attributes'
]
=
$attributes
;
...
...
@@ -156,6 +158,20 @@ abstract class Validator extends Component
}
/**
* @inheritdoc
*/
public
function
init
()
{
parent
::
init
();
if
(
!
is_array
(
$this
->
attributes
))
{
$this
->
attributes
=
(
array
)
$this
->
attributes
;
}
if
(
!
is_array
(
$this
->
on
))
{
$this
->
on
=
(
array
)
$this
->
on
;
}
}
/**
* Validates the specified object.
* @param \yii\base\Model $object the data object being validated
* @param array|null $attributes the list of attributes to be validated.
...
...
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