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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
c127171e
Commit
c127171e
authored
Oct 24, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #1003: DateValidator returned true for invalid dates
parent
7ce6325d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
1 deletion
+4
-1
DateValidator.php
framework/yii/validators/DateValidator.php
+3
-1
DateValidatorTest.php
tests/unit/framework/validators/DateValidatorTest.php
+1
-0
No files found.
framework/yii/validators/DateValidator.php
View file @
c127171e
...
@@ -70,6 +70,8 @@ class DateValidator extends Validator
...
@@ -70,6 +70,8 @@ class DateValidator extends Validator
*/
*/
public
function
validateValue
(
$value
)
public
function
validateValue
(
$value
)
{
{
return
DateTime
::
createFromFormat
(
$this
->
format
,
$value
)
!==
false
;
DateTime
::
createFromFormat
(
$this
->
format
,
$value
);
$errors
=
DateTime
::
getLastErrors
();
return
$errors
[
'error_count'
]
===
0
&&
$errors
[
'warning_count'
]
===
0
;
}
}
}
}
tests/unit/framework/validators/DateValidatorTest.php
View file @
c127171e
...
@@ -19,6 +19,7 @@ class DateValidatorTest extends TestCase
...
@@ -19,6 +19,7 @@ class DateValidatorTest extends TestCase
public
function
testValidateValue
()
public
function
testValidateValue
()
{
{
$val
=
new
DateValidator
;
$val
=
new
DateValidator
;
$this
->
assertFalse
(
$val
->
validateValue
(
'3232-32-32'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'2013-09-13'
));
$this
->
assertTrue
(
$val
->
validateValue
(
'2013-09-13'
));
$this
->
assertFalse
(
$val
->
validateValue
(
'31.7.2013'
));
$this
->
assertFalse
(
$val
->
validateValue
(
'31.7.2013'
));
$this
->
assertFalse
(
$val
->
validateValue
(
'31-7-2013'
));
$this
->
assertFalse
(
$val
->
validateValue
(
'31-7-2013'
));
...
...
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