Skip to content

Commit 81e0717

Browse files
authored
Merge pull request #27 from dipcode-software/fix/dates_validation
Fixed validation of dates
2 parents d33d6be + 498ab0c commit 81e0717

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [2.1.2] - 2018-04-21
8+
### Fixed
9+
- Validation of dates
10+
711
## [2.1.1] - 2018-04-20
812
### Fixed
913
- Forced choice value to be string when marking selected

src/Fields/TemporalField.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function __construct(array $args = array())
1818
parent::__construct($args);
1919
}
2020

21+
public function isValidDate($date_original, $date_created)
22+
{
23+
return $date_created && $date_created->format($this->format) == '!' . $date_original;
24+
}
25+
2126
public function toNative($value)
2227
{
2328
if (empty($value)) {
@@ -26,7 +31,7 @@ public function toNative($value)
2631

2732
$date = date_create_from_format($this->format, $value);
2833

29-
if (!$date) {
34+
if (!$date || !$this->isValidDate($value, $date)) {
3035
throw new ValidationError($this->error_messages['invalid'], 'invalid');
3136
}
3237

0 commit comments

Comments
 (0)