Skip to content

Commit 4aca4f5

Browse files
committed
Add support for full-date and full-time formats as aliases of date and time respectively, fixes #106
1 parent 48837c4 commit 4aca4f5

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

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

7+
## [0.12.30] - 2020-09-09
8+
9+
### Added
10+
- Support for `full-date` and `full-time` formats as aliases of `date` and `time` respectively.
11+
712
## [0.12.29] - 2020-03-19
813

914
### Added
@@ -58,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5863
### Changed
5964
- Export `null` value instead of skipping it for properties having `null` type.
6065

66+
[0.12.30]: https://github.com/swaggest/php-json-schema/compare/v0.12.29...v0.12.30
6167
[0.12.29]: https://github.com/swaggest/php-json-schema/compare/v0.12.28...v0.12.29
6268
[0.12.28]: https://github.com/swaggest/php-json-schema/compare/v0.12.27...v0.12.28
6369
[0.12.27]: https://github.com/swaggest/php-json-schema/compare/v0.12.26...v0.12.27

src/Constraint/Format.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class Format
1010
{
1111
const DATE_TIME = 'date-time';
1212
const DATE = 'date';
13+
const FULL_DATE = 'full-date';
1314
const TIME = 'time';
15+
const FULL_TIME = 'full-time';
1416
const URI = 'uri';
1517
const IRI = 'iri';
1618
const EMAIL = 'email';
@@ -40,8 +42,10 @@ public static function validationError($format, $data)
4042
case self::DATE_TIME:
4143
return self::dateTimeError($data);
4244
case self::DATE:
45+
case self::FULL_DATE:
4346
return preg_match('/^' . self::$dateRegexPart . '$/i', $data) ? null : 'Invalid date';
4447
case self::TIME:
48+
case self::FULL_TIME:
4549
return preg_match('/^' . self::$timeRegexPart . '$/i', $data) ? null : 'Invalid time';
4650
case self::URI:
4751
return Uri::validationError($data, Uri::IS_SCHEME_REQUIRED);

0 commit comments

Comments
 (0)