@@ -34,10 +34,9 @@ class SchemaError(ValueError):
3434
3535
3636class Validator (object ):
37- """ Validator class. Validates any Python dict
38- against a validation schema, which is provided as an argument at
39- class instantiation, or upon calling the :func:`validate` or
40- :func:`validate_update` methods.
37+ """ Validator class. Validates any Python dict against a validation schema,
38+ which is provided as an argument at class instantiation, or upon calling
39+ the :func:`validate` method.
4140
4241 :param schema: optional validation schema.
4342 :param transparent_schema_rules: if ``True`` unknown schema rules will be
@@ -55,9 +54,11 @@ class instantiation, or upon calling the :func:`validate` or
5554 field error' un validation.
5655
5756 .. versionchanged:: 0.4.0
58- 'type' validation is always performed first (only exception being
59- 'nullable'). On failure, it blocks other rules on the same field. Closes
60- #18.
57+ :func:`validate_update` is deprecated. Use :func:`validate` with
58+ ``update=True`` instead.
59+ Type validation is always performed first (only exception being
60+ ``nullable``). On failure, it blocks other rules on the same field.
61+ Closes #18.
6162
6263 .. versionadded:: 0.2.0
6364 `self.errors` returns an empty list when validate() has not been called.
@@ -87,8 +88,7 @@ def __init__(self, schema=None, transparent_schema_rules=False,
8788 def errors (self ):
8889 """
8990 :rtype: a list of validation errors. Will be empty if no errors
90- were found during. Resets after each call to :func:`validate`
91- or :func:`validate_update`.
91+ were found during. Resets after each call to :func:`validate`.
9292 """
9393 return self ._errors
9494
@@ -102,21 +102,29 @@ def validate_update(self, document, schema=None):
102102 class instantation.
103103 :return: True if validation succeeds, False otherwise. Check the
104104 :func:`errors` property for a list of validation errors.
105+
106+ .. deprecated:: 0.4.0
107+ Use :func:`validate` with ``update=True`` instead.
105108 """
106109 return self ._validate (document , schema , update = True )
107110
108- def validate (self , document , schema = None ):
111+ def validate (self , document , schema = None , update = False ):
109112 """ Validates a Python dictionary against a validation schema.
110113
111114 :param document: the dict to validate.
112115 :param schema: the validation schema. Defaults to ``None``. If not
113116 provided here, the schema must have been provided at
114117 class instantation.
118+ :param update: If ``True`` validation of required fields won't be
119+ performed.
115120
116121 :return: True if validation succeeds, False otherwise. Check the
117122 :func:`errors` property for a list of validation errors.
123+
124+ .. versionchanged:: 0.4.0
125+ Support for update mode.
118126 """
119- return self ._validate (document , schema , update = False )
127+ return self ._validate (document , schema , update = update )
120128
121129 def _validate (self , document , schema = None , update = False ):
122130
0 commit comments