Raise a ValidationError corresponding to the first unsatisfied constraint during entity validation

This prevents the wrong error message to be displayed when one has a vocabulary constraint for which a size constraint is also automatically added. Without the break, an error relative to the latter constraint will be raised whereas the user has actually specified the former. This is also consistent with other checks done in the method (stop on first "failure").

Closes #202779.

authorDenis Laxalde <denis.laxalde@logilab.fr>
changeset099fa63a02f0
branchdefault
phasepublic
hiddenno
parent revision#d6beabec7bb3 Don't raise an error on attempt to overwrite an infered relation
child revision#b8ac32c3a3d4 0.39.1
files modified by this revision
schema.py
# HG changeset patch
# User Denis Laxalde <denis.laxalde@logilab.fr>
# Date 1389866072 -3600
# Thu Jan 16 10:54:32 2014 +0100
# Node ID 099fa63a02f0f70901639b2b10e1c740ab9933c0
# Parent d6beabec7bb3d87365bb3ef412755f7854f80f80
Raise a ValidationError corresponding to the first unsatisfied constraint during entity validation

This prevents the wrong error message to be displayed when one has a
vocabulary constraint for which a size constraint is also automatically added.
Without the break, an error relative to the latter constraint will be raised
whereas the user has actually specified the former. This is also consistent
with other checks done in the method (stop on first "failure").

Closes #202779.

diff --git a/schema.py b/schema.py
@@ -546,10 +546,11 @@
1              for constraint in rdef.constraints:
2                  if not constraint.check(entity, rschema, value):
3                      msg, args = constraint.failed_message(qname, value)
4                      errors[qname] = msg
5                      msgargs.update(args)
6 +                    break
7          if errors:
8              raise ValidationError(entity, errors, msgargs, i18nvalues)
9 
10      def check_value(self, value):
11          """check the value of a final entity (ie a const value)"""