Skip to content

Commit

Permalink
Add maxlength minlength examples
Browse files Browse the repository at this point in the history
Signed-off-by: Vipul Gupta (@vipulgupta2048) <[email protected]>
  • Loading branch information
vipulgupta2048 committed Aug 19, 2019
1 parent c02fe31 commit 03be019
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Contributors
- Waldir Pimenta
- calve
- gilbsgilbs
- Vipul Gupta

A full, up-to-date list of contributors is available from git with:

Expand Down
19 changes: 18 additions & 1 deletion docs/validation-rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ 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 types that implement comparison operators. See
`\*of-rules`_ for examples.

.. versionchanged:: 1.0
Allows any type to be compared.
Expand All @@ -457,6 +458,22 @@ minlength, maxlength

Minimum and maximum length allowed for iterables.

.. doctest::

>>> schema = {'numbers': {'type': 'list', '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 03be019

Please sign in to comment.