We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 69c6823 commit d9d5fe1Copy full SHA for d9d5fe1
jsonschema/_format.py
@@ -319,15 +319,17 @@ def is_regex(instance):
319
return re.compile(instance)
320
321
322
+if hasattr(datetime.date, "fromisoformat"):
323
+ _is_date = datetime.date.fromisoformat
324
+else:
325
+ def _is_date(instance):
326
+ return datetime.datetime.strptime(instance, "%Y-%m-%d")
327
+
328
329
@_checks_drafts(draft3="date", draft7="date", raises=ValueError)
330
def is_date(instance):
331
if not isinstance(instance, str):
332
return True
- if hasattr(datetime.date, "fromisoformat"):
- _is_date = datetime.date.fromisoformat
- else:
- def _is_date(instance):
- return datetime.datetime.strptime(instance, "%Y-%m-%d")
333
return _is_date(instance)
334
335
0 commit comments