summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2013-06-17 21:19:29 -0400
committerJulian Berman <Julian@GrayVines.com>2013-06-17 21:19:29 -0400
commitf49fe39a228234d37f534074c5c121de44511ef2 (patch)
tree25b16cdae42e6700513eb9e51093832c8cf2050b
parent766c02b725b372a04783c4082463106cb0b354dd (diff)
downloadjsonschema-f49fe39a228234d37f534074c5c121de44511ef2.tar.gz
Only allow RFC 3339 date times, not all of ISO 8601.
Closes #115
-rw-r--r--docs/validate.rst10
-rw-r--r--jsonschema/_format.py13
-rw-r--r--tox.ini2
3 files changed, 19 insertions, 6 deletions
diff --git a/docs/validate.rst b/docs/validate.rst
index f4ad271..9490efe 100644
--- a/docs/validate.rst
+++ b/docs/validate.rst
@@ -284,7 +284,7 @@ ipv4
ipv6 OS must have :func:`socket.inet_pton` function
email
uri requires rfc3987_
-date-time requires isodate_
+date-time requires strict-rfc3339_ [#]_
date
time
regex
@@ -292,6 +292,14 @@ color requires webcolors_
========== ====================
+.. [#] For backwards compatibility, isodate_ is also supported, but it will
+ allow any `ISO 8601 <http://en.wikipedia.org/wiki/ISO_8601>`_ date-time,
+ not just `RFC 3339 <http://www.ietf.org/rfc/rfc3339.txt>`_ as mandated by
+ the JSON Schema specification.
+
+
+.. _isodate: http://pypi.python.org/pypi/isodate/
.. _isodate: http://pypi.python.org/pypi/isodate/
.. _rfc3987: http://pypi.python.org/pypi/rfc3987/
+.. _strict-rfc3339: http://pypi.python.org/pypi/strict-rfc3339/
.. _webcolors: http://pypi.python.org/pypi/webcolors/
diff --git a/jsonschema/_format.py b/jsonschema/_format.py
index 3c5d6c5..edfe97d 100644
--- a/jsonschema/_format.py
+++ b/jsonschema/_format.py
@@ -154,12 +154,17 @@ else:
try:
- import isodate
+ import strict_rfc3339
except ImportError:
- pass
+ try:
+ import isodate
+ except ImportError:
+ pass
+ else:
+ _err = (ValueError, isodate.ISO8601Error)
+ _checks_drafts("date-time", raises=_err)(isodate.parse_datetime)
else:
- _err = (ValueError, isodate.ISO8601Error)
- _checks_drafts("date-time", raises=_err)(isodate.parse_datetime)
+ _checks_drafts("date-time")(strict_rfc3339.validate_rfc3339)
_checks_drafts("regex", raises=re.error)(re.compile)
diff --git a/tox.ini b/tox.ini
index d1f390d..05dbbbf 100644
--- a/tox.ini
+++ b/tox.ini
@@ -49,10 +49,10 @@ deps =
[testenv:all]
deps =
- isodate
lxml
pytest
sphinx
+ strict-rfc3339
webcolors
[flake8]