Skip to content

Commit

Permalink
Merge branch 'pull_509' into 1.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
funkyfuture committed Aug 26, 2019
2 parents c02fe31 + 78f9a14 commit 0fccd9b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Contributors
- Sergey Leshchenko
- Tobias Betz
- Trong Hieu HA
- Vipul Gupta
- Waldir Pimenta
- calve
- gilbsgilbs
Expand Down
34 changes: 32 additions & 2 deletions docs/validation-rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,22 @@ The assigned data can be of any type.
min, max
--------

Minimum and maximum value allowed for any types that implement comparison operators.
Minimum and maximum value allowed for any object whose class implements
comparison operations (``__gt__`` & ``__lt__``).

.. doctest::

>>> schema = {'weight': {'min': 10.1, 'max': 10.9}}
>>> document = {'weight': 10.3}
>>> v.validate(document, schema)
True

>>> document = {'weight': 12}
>>> v.validate(document, schema)
False

>>> v.errors
{'weight': ['max value is 10.9']}

.. versionchanged:: 1.0
Allows any type to be compared.
Expand All @@ -455,7 +470,22 @@ Minimum and maximum value allowed for any types that implement comparison operat
minlength, maxlength
--------------------

Minimum and maximum length allowed for iterables.
Minimum and maximum length allowed for sized types that implement ``__len__``.

.. doctest::

>>> schema = {'numbers': {'minlength': 1, 'maxlength': 3}}
>>> document = {'numbers': [256, 2048, 23]}
>>> v.validate(document, schema)
True

>>> document = {'numbers': [256, 2048, 23, 2]}
>>> v.validate(document, schema)
False

>>> v.errors
{'numbers': ['max length is 3']}


noneof
------
Expand Down

0 comments on commit 0fccd9b

Please sign in to comment.