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
5ab1d1a0
Commit
5ab1d1a0
authored
Jan 24, 2015
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #6992.
parent
5ab58ac1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
4 deletions
+7
-4
input-validation.md
docs/guide/input-validation.md
+1
-1
InlineValidator.php
framework/validators/InlineValidator.php
+4
-2
ValidatorTest.php
tests/unit/framework/validators/ValidatorTest.php
+2
-1
No files found.
docs/guide/input-validation.md
View file @
5ab1d1a0
...
@@ -312,7 +312,7 @@ the method/function is:
...
@@ -312,7 +312,7 @@ the method/function is:
```
php
```
php
/**
/**
* @param string $attribute the attribute currently being validated
* @param string $attribute the attribute currently being validated
* @param
array $params the additional name-value pairs
given in the rule
* @param
mixed $params the value of the "params"
given in the rule
*/
*/
function
(
$attribute
,
$params
)
function
(
$attribute
,
$params
)
```
```
...
...
framework/validators/InlineValidator.php
View file @
5ab1d1a0
...
@@ -26,7 +26,9 @@ class InlineValidator extends Validator
...
@@ -26,7 +26,9 @@ class InlineValidator extends Validator
{
{
/**
/**
* @var string|\Closure an anonymous function or the name of a model class method that will be
* @var string|\Closure an anonymous function or the name of a model class method that will be
* called to perform the actual validation. The signature of the method should be like the following:
* called to perform the actual validation. The signature of the method should be like the following,
* where `$attribute` is the name of the attribute to be validated, and `$params` contains the value
* of [[params]] that you specify when declaring the inline validation rule:
*
*
* ~~~
* ~~~
* function foo($attribute, $params)
* function foo($attribute, $params)
...
@@ -34,7 +36,7 @@ class InlineValidator extends Validator
...
@@ -34,7 +36,7 @@ class InlineValidator extends Validator
*/
*/
public
$method
;
public
$method
;
/**
/**
* @var
array
additional parameters that are passed to the validation method
* @var
mixed
additional parameters that are passed to the validation method
*/
*/
public
$params
;
public
$params
;
/**
/**
...
...
tests/unit/framework/validators/ValidatorTest.php
View file @
5ab1d1a0
...
@@ -57,9 +57,10 @@ class ValidatorTest extends TestCase
...
@@ -57,9 +57,10 @@ class ValidatorTest extends TestCase
$this
->
assertInstanceOf
(
BooleanValidator
::
className
(),
$val
);
$this
->
assertInstanceOf
(
BooleanValidator
::
className
(),
$val
);
$this
->
assertSame
([
'a'
,
'b'
],
$val
->
on
);
$this
->
assertSame
([
'a'
,
'b'
],
$val
->
on
);
$this
->
assertSame
([
'c'
,
'd'
,
'e'
],
$val
->
except
);
$this
->
assertSame
([
'c'
,
'd'
,
'e'
],
$val
->
except
);
$val
=
TestValidator
::
createValidator
(
'inlineVal'
,
$model
,
[
'val_attr_a'
]);
$val
=
TestValidator
::
createValidator
(
'inlineVal'
,
$model
,
[
'val_attr_a'
]
,
[
'params'
=>
[
'foo'
=>
'bar'
]]
);
$this
->
assertInstanceOf
(
InlineValidator
::
className
(),
$val
);
$this
->
assertInstanceOf
(
InlineValidator
::
className
(),
$val
);
$this
->
assertSame
(
'inlineVal'
,
$val
->
method
);
$this
->
assertSame
(
'inlineVal'
,
$val
->
method
);
$this
->
assertSame
([
'foo'
=>
'bar'
],
$val
->
params
);
}
}
public
function
testValidate
()
public
function
testValidate
()
...
...
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