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
ef4ed7c8
Commit
ef4ed7c8
authored
Jul 22, 2011
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
w
parent
ab3e3601
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
147 additions
and
122 deletions
+147
-122
BooleanValidator.php
framework/validators/BooleanValidator.php
+4
-4
CaptchaValidator.php
framework/validators/CaptchaValidator.php
+4
-4
CompareValidator.php
framework/validators/CompareValidator.php
+4
-4
DateValidator.php
framework/validators/DateValidator.php
+2
-2
DefaultValueValidator.php
framework/validators/DefaultValueValidator.php
+2
-2
EmailValidator.php
framework/validators/EmailValidator.php
+3
-3
ExistValidator.php
framework/validators/ExistValidator.php
+2
-2
FileValidator.php
framework/validators/FileValidator.php
+5
-5
FilterValidator.php
framework/validators/FilterValidator.php
+2
-2
InlineValidator.php
framework/validators/InlineValidator.php
+15
-9
NumberValidator.php
framework/validators/NumberValidator.php
+5
-5
RangeValidator.php
framework/validators/RangeValidator.php
+4
-4
RegularExpressionValidator.php
framework/validators/RegularExpressionValidator.php
+3
-3
RequiredValidator.php
framework/validators/RequiredValidator.php
+38
-17
SafeValidator.php
framework/validators/SafeValidator.php
+2
-2
StringValidator.php
framework/validators/StringValidator.php
+5
-5
TypeValidator.php
framework/validators/TypeValidator.php
+2
-2
UniqueValidator.php
framework/validators/UniqueValidator.php
+2
-2
UnsafeValidator.php
framework/validators/UnsafeValidator.php
+2
-2
UrlValidator.php
framework/validators/UrlValidator.php
+4
-4
Validator.php
framework/validators/Validator.php
+37
-39
No files found.
framework/validators/BooleanValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0.10
* @since 1.0.10
*/
*/
class
CBooleanValidator
extends
C
Validator
class
CBooleanValidator
extends
Validator
{
{
/**
/**
* @var mixed the value representing true status. Defaults to '1'.
* @var mixed the value representing true status. Defaults to '1'.
...
@@ -45,7 +45,7 @@ class CBooleanValidator extends CValidator
...
@@ -45,7 +45,7 @@ class CBooleanValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -78,8 +78,8 @@ class CBooleanValidator extends CValidator
...
@@ -78,8 +78,8 @@ class CBooleanValidator extends CValidator
'{false}'
=>
$this
->
falseValue
,
'{false}'
=>
$this
->
falseValue
,
));
));
return
"
return
"
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
"value!="
.
CJSON
::
encode
(
$this
->
trueValue
)
.
" && value!="
.
CJSON
::
encode
(
$this
->
falseValue
)
.
") {
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
"value!="
.
json_encode
(
$this
->
trueValue
)
.
" && value!="
.
json_
encode
(
$this
->
falseValue
)
.
") {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/CaptchaValidator.php
View file @
ef4ed7c8
...
@@ -19,7 +19,7 @@ namespace yii\validators;
...
@@ -19,7 +19,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CCaptchaValidator
extends
C
Validator
class
CCaptchaValidator
extends
Validator
{
{
/**
/**
* @var boolean whether the comparison is case sensitive. Defaults to false.
* @var boolean whether the comparison is case sensitive. Defaults to false.
...
@@ -43,7 +43,7 @@ class CCaptchaValidator extends CValidator
...
@@ -43,7 +43,7 @@ class CCaptchaValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -61,7 +61,7 @@ class CCaptchaValidator extends CValidator
...
@@ -61,7 +61,7 @@ class CCaptchaValidator extends CValidator
* @return CCaptchaAction the action object
* @return CCaptchaAction the action object
* @since 1.1.7
* @since 1.1.7
*/
*/
p
rotected
function
getCaptchaAction
()
p
ublic
function
getCaptchaAction
()
{
{
if
((
$captcha
=
Yii
::
app
()
->
getController
()
->
createAction
(
$this
->
captchaAction
))
===
null
)
if
((
$captcha
=
Yii
::
app
()
->
getController
()
->
createAction
(
$this
->
captchaAction
))
===
null
)
{
{
...
@@ -105,7 +105,7 @@ else
...
@@ -105,7 +105,7 @@ else
hash = hash["
.
(
$this
->
caseSensitive
?
0
:
1
)
.
"];
hash = hash["
.
(
$this
->
caseSensitive
?
0
:
1
)
.
"];
for(var i=value.length-1, h=0; i >= 0; --i) h+=value."
.
(
$this
->
caseSensitive
?
''
:
'toLowerCase().'
)
.
"charCodeAt(i);
for(var i=value.length-1, h=0; i >= 0; --i) h+=value."
.
(
$this
->
caseSensitive
?
''
:
'toLowerCase().'
)
.
"charCodeAt(i);
if(h != hash) {
if(h != hash) {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
...
...
framework/validators/CompareValidator.php
View file @
ef4ed7c8
...
@@ -29,7 +29,7 @@ namespace yii\validators;
...
@@ -29,7 +29,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CCompareValidator
extends
C
Validator
class
CCompareValidator
extends
Validator
{
{
/**
/**
* @var string the name of the attribute to be compared with
* @var string the name of the attribute to be compared with
...
@@ -72,7 +72,7 @@ class CCompareValidator extends CValidator
...
@@ -72,7 +72,7 @@ class CCompareValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -149,7 +149,7 @@ class CCompareValidator extends CValidator
...
@@ -149,7 +149,7 @@ class CCompareValidator extends CValidator
if
(
$this
->
compareValue
!==
null
)
if
(
$this
->
compareValue
!==
null
)
{
{
$compareTo
=
$this
->
compareValue
;
$compareTo
=
$this
->
compareValue
;
$compareValue
=
CJSON
::
encode
(
$this
->
compareValue
);
$compareValue
=
json_
encode
(
$this
->
compareValue
);
}
}
else
else
{
{
...
@@ -203,7 +203,7 @@ class CCompareValidator extends CValidator
...
@@ -203,7 +203,7 @@ class CCompareValidator extends CValidator
return
"
return
"
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
$condition
.
") {
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
$condition
.
") {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/DateValidator.php
View file @
ef4ed7c8
...
@@ -20,7 +20,7 @@ namespace yii\validators;
...
@@ -20,7 +20,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.1.7
* @since 1.1.7
*/
*/
class
CDateValidator
extends
C
Validator
class
CDateValidator
extends
Validator
{
{
/**
/**
* @var mixed the format pattern that the date value should follow.
* @var mixed the format pattern that the date value should follow.
...
@@ -47,7 +47,7 @@ class CDateValidator extends CValidator
...
@@ -47,7 +47,7 @@ class CDateValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
...
framework/validators/DefaultValueValidator.php
View file @
ef4ed7c8
...
@@ -19,7 +19,7 @@ namespace yii\validators;
...
@@ -19,7 +19,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0.2
* @since 1.0.2
*/
*/
class
CDefaultValueValidator
extends
C
Validator
class
CDefaultValueValidator
extends
Validator
{
{
/**
/**
* @var mixed the default value to be set to the specified attributes.
* @var mixed the default value to be set to the specified attributes.
...
@@ -37,7 +37,7 @@ class CDefaultValueValidator extends CValidator
...
@@ -37,7 +37,7 @@ class CDefaultValueValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
if
(
!
$this
->
setOnEmpty
)
if
(
!
$this
->
setOnEmpty
)
$object
->
$attribute
=
$this
->
value
;
$object
->
$attribute
=
$this
->
value
;
...
...
framework/validators/EmailValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CEmailValidator
extends
C
Validator
class
CEmailValidator
extends
Validator
{
{
/**
/**
* @var string the regular expression used to validate the attribute value.
* @var string the regular expression used to validate the attribute value.
...
@@ -61,7 +61,7 @@ class CEmailValidator extends CValidator
...
@@ -61,7 +61,7 @@ class CEmailValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -115,7 +115,7 @@ class CEmailValidator extends CValidator
...
@@ -115,7 +115,7 @@ class CEmailValidator extends CValidator
return
"
return
"
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
$condition
.
") {
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
$condition
.
") {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/ExistValidator.php
View file @
ef4ed7c8
...
@@ -20,7 +20,7 @@ namespace yii\validators;
...
@@ -20,7 +20,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0.4
* @since 1.0.4
*/
*/
class
CExistValidator
extends
C
Validator
class
CExistValidator
extends
Validator
{
{
/**
/**
* @var string the ActiveRecord class name that should be used to
* @var string the ActiveRecord class name that should be used to
...
@@ -56,7 +56,7 @@ class CExistValidator extends CValidator
...
@@ -56,7 +56,7 @@ class CExistValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
...
framework/validators/FileValidator.php
View file @
ef4ed7c8
...
@@ -44,7 +44,7 @@ namespace yii\validators;
...
@@ -44,7 +44,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CFileValidator
extends
C
Validator
class
CFileValidator
extends
Validator
{
{
/**
/**
* @var boolean whether the attribute requires a file to be uploaded or not.
* @var boolean whether the attribute requires a file to be uploaded or not.
...
@@ -106,7 +106,7 @@ class CFileValidator extends CValidator
...
@@ -106,7 +106,7 @@ class CFileValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
if
(
$this
->
maxFiles
>
1
)
if
(
$this
->
maxFiles
>
1
)
{
{
...
@@ -143,7 +143,7 @@ class CFileValidator extends CValidator
...
@@ -143,7 +143,7 @@ class CFileValidator extends CValidator
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
* @param CUploadedFile $file uploaded file passed to check against a set of rules
* @param CUploadedFile $file uploaded file passed to check against a set of rules
*/
*/
p
rotected
function
validateFile
(
$object
,
$attribute
,
$file
)
p
ublic
function
validateFile
(
$object
,
$attribute
,
$file
)
{
{
if
(
null
===
$file
||
(
$error
=
$file
->
getError
())
==
UPLOAD_ERR_NO_FILE
)
if
(
null
===
$file
||
(
$error
=
$file
->
getError
())
==
UPLOAD_ERR_NO_FILE
)
return
$this
->
emptyAttribute
(
$object
,
$attribute
);
return
$this
->
emptyAttribute
(
$object
,
$attribute
);
...
@@ -186,7 +186,7 @@ class CFileValidator extends CValidator
...
@@ -186,7 +186,7 @@ class CFileValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
emptyAttribute
(
$object
,
$attribute
)
p
ublic
function
emptyAttribute
(
$object
,
$attribute
)
{
{
if
(
!
$this
->
allowEmpty
)
if
(
!
$this
->
allowEmpty
)
{
{
...
@@ -206,7 +206,7 @@ class CFileValidator extends CValidator
...
@@ -206,7 +206,7 @@ class CFileValidator extends CValidator
*
*
* @return integer the size limit for uploaded files.
* @return integer the size limit for uploaded files.
*/
*/
p
rotected
function
getSizeLimit
()
p
ublic
function
getSizeLimit
()
{
{
$limit
=
ini_get
(
'upload_max_filesize'
);
$limit
=
ini_get
(
'upload_max_filesize'
);
$limit
=
$this
->
sizeToBytes
(
$limit
);
$limit
=
$this
->
sizeToBytes
(
$limit
);
...
...
framework/validators/FilterValidator.php
View file @
ef4ed7c8
...
@@ -28,7 +28,7 @@ namespace yii\validators;
...
@@ -28,7 +28,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CFilterValidator
extends
C
Validator
class
CFilterValidator
extends
Validator
{
{
/**
/**
* @var callback the filter method
* @var callback the filter method
...
@@ -41,7 +41,7 @@ class CFilterValidator extends CValidator
...
@@ -41,7 +41,7 @@ class CFilterValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
if
(
$this
->
filter
===
null
||
!
is_callable
(
$this
->
filter
))
if
(
$this
->
filter
===
null
||
!
is_callable
(
$this
->
filter
))
throw
new
CException
(
Yii
::
t
(
'yii'
,
'The "filter" property must be specified with a valid callback.'
));
throw
new
CException
(
Yii
::
t
(
'yii'
,
'The "filter" property must be specified with a valid callback.'
));
...
...
framework/validators/InlineValidator.php
View file @
ef4ed7c8
<?php
<?php
/**
/**
*
C
InlineValidator class file.
* InlineValidator class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
...
@@ -10,14 +10,21 @@
...
@@ -10,14 +10,21 @@
namespace
yii\validators
;
namespace
yii\validators
;
/**
/**
* CInlineValidator represents a validator which is defined as a method in the object being validated.
* InlineValidator represents a validator which is defined as a method in the object being validated.
*
* The validation method must have the following signature:
*
* ~~~
* function foo($attribute, $params)
* ~~~
*
* where `$attribute` refers to the name of the attribute being validated, while `$params`
* is an array representing the additional parameters supplied in the validation rule.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id: CInlineValidator.php 2799 2011-01-01 19:31:13Z qiang.xue $
* @since 2.0
* @package system.validators
* @since 1.0
*/
*/
class
CInlineValidator
extends
C
Validator
class
InlineValidator
extends
Validator
{
{
/**
/**
* @var string the name of the validation method defined in the active record class
* @var string the name of the validation method defined in the active record class
...
@@ -30,11 +37,10 @@ class CInlineValidator extends CValidator
...
@@ -30,11 +37,10 @@ class CInlineValidator extends CValidator
/**
/**
* Validates the attribute of the object.
* Validates the attribute of the object.
* If there is any error, the error message is added to the object.
* @param \yii\base\Model $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$method
=
$this
->
method
;
$method
=
$this
->
method
;
$object
->
$method
(
$attribute
,
$this
->
params
);
$object
->
$method
(
$attribute
,
$this
->
params
);
...
...
framework/validators/NumberValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CNumberValidator
extends
C
Validator
class
CNumberValidator
extends
Validator
{
{
/**
/**
* @var boolean whether the attribute value can only be an integer. Defaults to false.
* @var boolean whether the attribute value can only be an integer. Defaults to false.
...
@@ -62,7 +62,7 @@ class CNumberValidator extends CValidator
...
@@ -62,7 +62,7 @@ class CNumberValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -130,14 +130,14 @@ class CNumberValidator extends CValidator
...
@@ -130,14 +130,14 @@ class CNumberValidator extends CValidator
$pattern
=
$this
->
integerOnly
?
$this
->
integerPattern
:
$this
->
numberPattern
;
$pattern
=
$this
->
integerOnly
?
$this
->
integerPattern
:
$this
->
numberPattern
;
$js
=
"
$js
=
"
if(!value.match(
$pattern
)) {
if(!value.match(
$pattern
)) {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
if
(
$this
->
min
!==
null
)
if
(
$this
->
min
!==
null
)
{
{
$js
.=
"
$js
.=
"
if(value<
{
$this
->
min
}
) {
if(value<
{
$this
->
min
}
) {
messages.push("
.
CJSON
::
encode
(
$tooSmall
)
.
");
messages.push("
.
json_
encode
(
$tooSmall
)
.
");
}
}
"
;
"
;
}
}
...
@@ -145,7 +145,7 @@ if(value< {$this->min}) {
...
@@ -145,7 +145,7 @@ if(value< {$this->min}) {
{
{
$js
.=
"
$js
.=
"
if(value>
{
$this
->
max
}
) {
if(value>
{
$this
->
max
}
) {
messages.push("
.
CJSON
::
encode
(
$tooBig
)
.
");
messages.push("
.
json_
encode
(
$tooBig
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/RangeValidator.php
View file @
ef4ed7c8
...
@@ -18,7 +18,7 @@ namespace yii\validators;
...
@@ -18,7 +18,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CRangeValidator
extends
C
Validator
class
CRangeValidator
extends
Validator
{
{
/**
/**
* @var array list of valid values that the attribute value should be among
* @var array list of valid values that the attribute value should be among
...
@@ -46,7 +46,7 @@ class CRangeValidator extends CValidator
...
@@ -46,7 +46,7 @@ class CRangeValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -87,11 +87,11 @@ class CRangeValidator extends CValidator
...
@@ -87,11 +87,11 @@ class CRangeValidator extends CValidator
$range
=
array
();
$range
=
array
();
foreach
(
$this
->
range
as
$value
)
foreach
(
$this
->
range
as
$value
)
$range
[]
=
(
string
)
$value
;
$range
[]
=
(
string
)
$value
;
$range
=
CJSON
::
encode
(
$range
);
$range
=
json_
encode
(
$range
);
return
"
return
"
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
(
$this
->
not
?
"$.inArray(value,
$range
)>=0"
:
"$.inArray(value,
$range
)<0"
)
.
") {
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
(
$this
->
not
?
"$.inArray(value,
$range
)>=0"
:
"$.inArray(value,
$range
)<0"
)
.
") {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/RegularExpressionValidator.php
View file @
ef4ed7c8
...
@@ -18,7 +18,7 @@ namespace yii\validators;
...
@@ -18,7 +18,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CRegularExpressionValidator
extends
C
Validator
class
CRegularExpressionValidator
extends
Validator
{
{
/**
/**
* @var string the regular expression to be matched with
* @var string the regular expression to be matched with
...
@@ -42,7 +42,7 @@ class CRegularExpressionValidator extends CValidator
...
@@ -42,7 +42,7 @@ class CRegularExpressionValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -88,7 +88,7 @@ class CRegularExpressionValidator extends CValidator
...
@@ -88,7 +88,7 @@ class CRegularExpressionValidator extends CValidator
return
"
return
"
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
(
$this
->
not
?
''
:
'!'
)
.
"value.match(
$pattern
)) {
if("
.
(
$this
->
allowEmpty
?
"$.trim(value)!='' && "
:
''
)
.
(
$this
->
not
?
''
:
'!'
)
.
"value.match(
$pattern
)) {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/RequiredValidator.php
View file @
ef4ed7c8
<?php
<?php
/**
/**
*
C
RequiredValidator class file.
* RequiredValidator class file.
*
*
* @link http://www.yiiframework.com/
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2012 Yii Software LLC
* @copyright Copyright © 2008-2012 Yii Software LLC
...
@@ -10,39 +10,60 @@
...
@@ -10,39 +10,60 @@
namespace
yii\validators
;
namespace
yii\validators
;
/**
/**
*
C
RequiredValidator validates that the specified attribute does not have null or empty value.
* RequiredValidator validates that the specified attribute does not have null or empty value.
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id: CRequiredValidator.php 3157 2011-04-02 19:21:06Z qiang.xue $
* @since 2.0
* @package system.validators
* @since 1.0
*/
*/
class
CRequiredValidator
extends
C
Validator
class
RequiredValidator
extends
Validator
{
{
/**
/**
* @var mixed the desired value that the attribute must have.
* @var mixed the desired value that the attribute must have.
* If this is null, the validator will validate that the specified attribute
does not have null or empty value
.
* If this is null, the validator will validate that the specified attribute
is not empty
.
* If this is set as a value that is not null, the validator will validate that
* If this is set as a value that is not null, the validator will validate that
* the attribute has a value that is the same as this property value.
* the attribute has a value that is the same as this property value.
* Defaults to null.
* Defaults to null.
* @s
ince 1.0.10
* @s
ee strict
*/
*/
public
$requiredValue
;
public
$requiredValue
;
/**
/**
* @var boolean whether the comparison to {@link requiredValue} is strict.
* @var boolean whether the comparison between the attribute value and [[requiredValue]] is strict.
* When this is true, the attribute value and type must both match those of {@link requiredValue}.
* When this is true, both the values and types must match.
* Defaults to false, meaning only the value needs to be matched.
* Defaults to false, meaning only the values need to match.
* This property is only used when {@link requiredValue} is not null.
* Note that when [[requiredValue]] is null, if this property is true, the validator will check
* @since 1.0.10
* if the attribute value is null; If this property is false, the validator will call [[isEmpty]]
* to check if the attribute value is empty.
*/
*/
public
$strict
=
false
;
public
$strict
=
false
;
/**
* Validates a value.
* @param mixed $value the value being validated.
* @return boolean whether the value is valid.
*/
public
function
validateValue
(
$value
)
{
if
(
$this
->
requiredValue
!==
null
)
{
if
(
!
$this
->
strict
&&
$value
!=
$this
->
requiredValue
||
$this
->
strict
&&
$value
!==
$this
->
requiredValue
)
{
$message
=
$this
->
message
!==
null
?
$this
->
message
:
Yii
::
t
(
'yii'
,
'{attribute} must be {value}.'
,
array
(
'{value}'
=>
$this
->
requiredValue
));
$this
->
addError
(
$object
,
$attribute
,
$message
);
}
}
elseif
(
$this
->
isEmpty
(
$value
,
true
))
{
$message
=
$this
->
message
!==
null
?
$this
->
message
:
Yii
::
t
(
'yii'
,
'{attribute} cannot be blank.'
);
$this
->
addError
(
$object
,
$attribute
,
$message
);
}
}
/**
/**
* Validates the attribute of the object.
* Validates the attribute of the object.
* If there is any error, the error message is added to the object.
* If there is any error, the error message is added to the object.
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
requiredValue
!==
null
)
if
(
$this
->
requiredValue
!==
null
)
...
@@ -81,8 +102,8 @@ class CRequiredValidator extends CValidator
...
@@ -81,8 +102,8 @@ class CRequiredValidator extends CValidator
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
'{attribute}'
=>
$object
->
getAttributeLabel
(
$attribute
),
));
));
return
"
return
"
if(value!="
.
CJSON
::
encode
(
$this
->
requiredValue
)
.
") {
if(value!="
.
json_
encode
(
$this
->
requiredValue
)
.
") {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
@@ -95,7 +116,7 @@ if(value!=" . CJSON::encode($this->requiredValue) . ") {
...
@@ -95,7 +116,7 @@ if(value!=" . CJSON::encode($this->requiredValue) . ") {
));
));
return
"
return
"
if($.trim(value)=='') {
if($.trim(value)=='') {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/SafeValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.1
* @since 1.1
*/
*/
class
CSafeValidator
extends
C
Validator
class
CSafeValidator
extends
Validator
{
{
/**
/**
* Validates the attribute of the object.
* Validates the attribute of the object.
...
@@ -25,7 +25,7 @@ class CSafeValidator extends CValidator
...
@@ -25,7 +25,7 @@ class CSafeValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
}
}
}
}
...
...
framework/validators/StringValidator.php
View file @
ef4ed7c8
...
@@ -19,7 +19,7 @@ namespace yii\validators;
...
@@ -19,7 +19,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CStringValidator
extends
C
Validator
class
CStringValidator
extends
Validator
{
{
/**
/**
* @var integer maximum length. Defaults to null, meaning no maximum limit.
* @var integer maximum length. Defaults to null, meaning no maximum limit.
...
@@ -63,7 +63,7 @@ class CStringValidator extends CValidator
...
@@ -63,7 +63,7 @@ class CStringValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -129,7 +129,7 @@ class CStringValidator extends CValidator
...
@@ -129,7 +129,7 @@ class CStringValidator extends CValidator
{
{
$js
.=
"
$js
.=
"
if(value.length<
{
$this
->
min
}
) {
if(value.length<
{
$this
->
min
}
) {
messages.push("
.
CJSON
::
encode
(
$tooShort
)
.
");
messages.push("
.
json_
encode
(
$tooShort
)
.
");
}
}
"
;
"
;
}
}
...
@@ -137,7 +137,7 @@ if(value.length< {$this->min}) {
...
@@ -137,7 +137,7 @@ if(value.length< {$this->min}) {
{
{
$js
.=
"
$js
.=
"
if(value.length>
{
$this
->
max
}
) {
if(value.length>
{
$this
->
max
}
) {
messages.push("
.
CJSON
::
encode
(
$tooLong
)
.
");
messages.push("
.
json_
encode
(
$tooLong
)
.
");
}
}
"
;
"
;
}
}
...
@@ -145,7 +145,7 @@ if(value.length> {$this->max}) {
...
@@ -145,7 +145,7 @@ if(value.length> {$this->max}) {
{
{
$js
.=
"
$js
.=
"
if(value.length!=
{
$this
->
is
}
) {
if(value.length!=
{
$this
->
is
}
) {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
}
}
...
...
framework/validators/TypeValidator.php
View file @
ef4ed7c8
...
@@ -35,7 +35,7 @@ namespace yii\validators;
...
@@ -35,7 +35,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CTypeValidator
extends
C
Validator
class
CTypeValidator
extends
Validator
{
{
/**
/**
* @var string the data type that the attribute should be. Defaults to 'string'.
* @var string the data type that the attribute should be. Defaults to 'string'.
...
@@ -75,7 +75,7 @@ class CTypeValidator extends CValidator
...
@@ -75,7 +75,7 @@ class CTypeValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
...
framework/validators/UniqueValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CUniqueValidator
extends
C
Validator
class
CUniqueValidator
extends
Validator
{
{
/**
/**
* @var boolean whether the comparison is case sensitive. Defaults to true.
* @var boolean whether the comparison is case sensitive. Defaults to true.
...
@@ -72,7 +72,7 @@ class CUniqueValidator extends CValidator
...
@@ -72,7 +72,7 @@ class CUniqueValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
...
framework/validators/UnsafeValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CUnsafeValidator
extends
C
Validator
class
CUnsafeValidator
extends
Validator
{
{
/**
/**
* @var boolean whether attributes listed with this validator should be considered safe for massive assignment.
* @var boolean whether attributes listed with this validator should be considered safe for massive assignment.
...
@@ -31,7 +31,7 @@ class CUnsafeValidator extends CValidator
...
@@ -31,7 +31,7 @@ class CUnsafeValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
}
}
}
}
...
...
framework/validators/UrlValidator.php
View file @
ef4ed7c8
...
@@ -17,7 +17,7 @@ namespace yii\validators;
...
@@ -17,7 +17,7 @@ namespace yii\validators;
* @package system.validators
* @package system.validators
* @since 1.0
* @since 1.0
*/
*/
class
CUrlValidator
extends
C
Validator
class
CUrlValidator
extends
Validator
{
{
/**
/**
* @var string the regular expression used to validate the attribute value.
* @var string the regular expression used to validate the attribute value.
...
@@ -50,7 +50,7 @@ class CUrlValidator extends CValidator
...
@@ -50,7 +50,7 @@ class CUrlValidator extends CValidator
* @param CModel $object the object being validated
* @param CModel $object the object being validated
* @param string $attribute the attribute being validated
* @param string $attribute the attribute being validated
*/
*/
p
rotected
function
validateAttribute
(
$object
,
$attribute
)
p
ublic
function
validateAttribute
(
$object
,
$attribute
)
{
{
$value
=
$object
->
$attribute
;
$value
=
$object
->
$attribute
;
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
if
(
$this
->
allowEmpty
&&
$this
->
isEmpty
(
$value
))
...
@@ -112,14 +112,14 @@ class CUrlValidator extends CValidator
...
@@ -112,14 +112,14 @@ class CUrlValidator extends CValidator
$js
=
"
$js
=
"
if(!value.match(
$pattern
)) {
if(!value.match(
$pattern
)) {
messages.push("
.
CJSON
::
encode
(
$message
)
.
");
messages.push("
.
json_
encode
(
$message
)
.
");
}
}
"
;
"
;
if
(
$this
->
defaultScheme
!==
null
)
if
(
$this
->
defaultScheme
!==
null
)
{
{
$js
=
"
$js
=
"
if(!value.match(/:
\\
/
\\
//)) {
if(!value.match(/:
\\
/
\\
//)) {
value="
.
CJSON
::
encode
(
$this
->
defaultScheme
)
.
"+'://'+value;
value="
.
json_
encode
(
$this
->
defaultScheme
)
.
"+'://'+value;
}
}
$js
$js
"
;
"
;
...
...
framework/validators/Validator.php
View file @
ef4ed7c8
...
@@ -12,50 +12,44 @@ namespace yii\validators;
...
@@ -12,50 +12,44 @@ namespace yii\validators;
/**
/**
* Validator is the base class for all validators.
* Validator is the base class for all validators.
*
*
* Child classes must implement the {@link validateAttribute} method.
* Child classes may override the [[validateValue]] method to provide the actual
* logic of performing data validation.
*
*
* The following properties are defined in CValidator:
* Validator defines the following properties that are common among concrete validators:
* <ul>
* <li>{@link attributes}: array, list of attributes to be validated;</li>
* <li>{@link message}: string, the customized error message. The message
* may contain placeholders that will be replaced with the actual content.
* For example, the "{attribute}" placeholder will be replaced with the label
* of the problematic attribute. Different validators may define additional
* placeholders.</li>
* <li>{@link on}: string, in which scenario should the validator be in effect.
* This is used to match the 'on' parameter supplied when calling {@link CModel::validate}.</li>
* </ul>
*
*
* When using {@link createValidator} to create a validator, the following aliases
* - [[attributes]]: array, list of attributes to be validated;
* are recognized as the corresponding built-in validator classes:
* - [[message]]: string, the error message used when validation fails;
* <ul>
* - [[on]]: string, scenarios on which the validator applies.
* <li>required: {@link CRequiredValidator}</li>
*
* <li>filter: {@link CFilterValidator}</li>
* Validator also declares a set of [[builtInValidators|built-in validators] which can
* <li>match: {@link CRegularExpressionValidator}</li>
* be referenced using short names. They are listed as follows:
* <li>email: {@link CEmailValidator}</li>
*
* <li>url: {@link CUrlValidator}</li>
* - `required`: [[RequiredValidator]]
* <li>unique: {@link CUniqueValidator}</li>
* - `filter`: [[FilterValidator]]
* <li>compare: {@link CCompareValidator}</li>
* - `match`: [[RegularExpressionValidator]]
* <li>length: {@link CStringValidator}</li>
* - `email`: [[EmailValidator]]
* <li>in: {@link CRangeValidator}</li>
* - `url`: [[UrlValidator]]
* <li>numerical: {@link CNumberValidator}</li>
* - `unique`: [[UniqueValidator]]
* <li>captcha: {@link CCaptchaValidator}</li>
* - `compare`: [[CompareValidator]]
* <li>type: {@link CTypeValidator}</li>
* - `length`: [[StringValidator]]
* <li>file: {@link CFileValidator}</li>
* - `in`: [[RangeValidator]]
* <li>default: {@link CDefaultValueValidator}</li>
* - `numerical`: [[NumberValidator]]
* <li>exist: {@link CExistValidator}</li>
* - `captcha`: [[CaptchaValidator]]
* <li>boolean: {@link CBooleanValidator}</li>
* - `type`: [[TypeValidator]]
* <li>date: {@link CDateValidator}</li>
* - `file`: [[FileValidator]]
* <li>safe: {@link CSafeValidator}</li>
* - `default`: [[DefaultValueValidator]]
* <li>unsafe: {@link CUnsafeValidator}</li>
* - `exist`: [[ExistValidator]]
* </ul>
* - `boolean`: [[BooleanValidator]]
* - `date`: [[DateValidator]]
* - `safe`: [[SafeValidator]]
* - `unsafe`: [[UnsafeValidator]]
*
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Id: CValidator.php 3160 2011-04-03 01:08:23Z qiang.xue $
* @version $Id: CValidator.php 3160 2011-04-03 01:08:23Z qiang.xue $
* @package system.validators
* @package system.validators
* @since 2.0
* @since 2.0
*/
*/
abstract
class
Validator
extends
\yii\base\Component
class
Validator
extends
\yii\base\Component
{
{
/**
/**
* @var array list of built-in validators (name => class or configuration)
* @var array list of built-in validators (name => class or configuration)
...
@@ -125,10 +119,14 @@ abstract class Validator extends \yii\base\Component
...
@@ -125,10 +119,14 @@ abstract class Validator extends \yii\base\Component
/**
/**
* Validates a value.
* Validates a value.
* Child classes should override this method to implement the actual validation logic.
* Child classes should override this method to implement the actual validation logic.
* The default implementation simply returns true.
* @param mixed $value the value being validated.
* @param mixed $value the value being validated.
* @return boolean whether the value is valid.
* @return boolean whether the value is valid.
*/
*/
abstract
public
function
validateValue
(
$value
);
public
function
validateValue
(
$value
)
{
return
true
;
}
/**
/**
* Validates a single attribute.
* Validates a single attribute.
...
@@ -265,7 +263,7 @@ abstract class Validator extends \yii\base\Component
...
@@ -265,7 +263,7 @@ abstract class Validator extends \yii\base\Component
* @param string $message the error message
* @param string $message the error message
* @param array $params values for the placeholders in the error message
* @param array $params values for the placeholders in the error message
*/
*/
p
rotected
function
addError
(
$object
,
$attribute
,
$message
,
$params
=
array
())
p
ublic
function
addError
(
$object
,
$attribute
,
$message
,
$params
=
array
())
{
{
$params
[
'{attribute}'
]
=
$object
->
getAttributeLabel
(
$attribute
);
$params
[
'{attribute}'
]
=
$object
->
getAttributeLabel
(
$attribute
);
$params
[
'{value}'
]
=
$object
->
$attribute
;
$params
[
'{value}'
]
=
$object
->
$attribute
;
...
@@ -280,7 +278,7 @@ abstract class Validator extends \yii\base\Component
...
@@ -280,7 +278,7 @@ abstract class Validator extends \yii\base\Component
* @param boolean $trim whether to perform trimming before checking if the string is empty. Defaults to false.
* @param boolean $trim whether to perform trimming before checking if the string is empty. Defaults to false.
* @return boolean whether the value is empty
* @return boolean whether the value is empty
*/
*/
p
rotected
function
isEmpty
(
$value
,
$trim
=
false
)
p
ublic
function
isEmpty
(
$value
,
$trim
=
false
)
{
{
return
$value
===
null
||
$value
===
array
()
||
$value
===
''
return
$value
===
null
||
$value
===
array
()
||
$value
===
''
||
$trim
&&
is_scalar
(
$value
)
&&
trim
(
$value
)
===
''
;
||
$trim
&&
is_scalar
(
$value
)
&&
trim
(
$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