Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Fixed `propertyNames: false` crashing on non-object values
* Added type annotations for public API and `py.typed` marker (PEP 561)
* Added `message` to `JsonSchemaValuesException` joining messages of all collected errors
* Fixed the `date-time` format accepting months, days and hours out of range (such as `2020-19-39T29:00:00Z`) and rejecting a leap second (`23:59:60Z`)

=== 2.22.2 (2026-08-15)

Expand Down
2 changes: 1 addition & 1 deletion fastjsonschema/draft04.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CodeGeneratorDraft04(CodeGenerator):
# vs. 9 ms with a regex! Other modules are also ineffective or not available in standard
# library. Some regexps are not 100% precise but good enough, fast and without dependencies.
FORMAT_REGEXS = {
'date-time': r'^\d{4}-[01]\d-[0-3]\d(t|T)[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|[+-][0-2]\d[0-5]\d|z|Z)\Z',
'date-time': r'^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(t|T)(?:[01]\d|2[0-3]):[0-5]\d:(?:[0-5]\d|60)(?:\.\d+)?(?:[+-](?:[01]\d|2[0-3]):[0-5]\d|[+-](?:[01]\d|2[0-3])[0-5]\d|z|Z)\Z',
'email': r'^(?!.*\.\..*@)[^@.][^@]*(?<!\.)@[^@]+\.[^@]+\Z',
'hostname': r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]{0,61}[A-Za-z0-9])\Z',
'ipv4': r'^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\Z',
Expand Down
13 changes: 13 additions & 0 deletions tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
('2018-02-05T14:17:10.00Z', '2018-02-05T14:17:10.00Z'),
('2018-02-05T14:17:10Z', '2018-02-05T14:17:10Z'),
('2020-09-09T01:01:01+0100', '2020-09-09T01:01:01+0100'),
('1998-12-31T23:59:60Z', '1998-12-31T23:59:60Z'),
('1990-12-31T15:59:60-08:00', '1990-12-31T15:59:60-08:00'),
('2020-00-10T01:01:01Z', exc),
('2020-13-10T01:01:01Z', exc),
('2020-19-10T01:01:01Z', exc),
('2020-01-00T01:01:01Z', exc),
('2020-01-32T01:01:01Z', exc),
('2020-01-39T01:01:01Z', exc),
('2020-01-01T24:00:00Z', exc),
('2020-01-01T29:00:00Z', exc),
('2020-01-01T01:01:61Z', exc),
('2020-01-01T01:01:01+24:00', exc),
('2020-01-01T01:01:01+01:60', exc),
])
def test_datetime(asserter, value, expected):
asserter({'type': 'string', 'format': 'date-time'}, value, expected)
Expand Down
Loading