yams #202779 validation error of vocabulary constraint reports misleading error about size constraint [validation pending]
Assuming you have a vocabulary constraint on an attribute, a size constraint will be added automatically (see set_vocabulary() method in buildobjs). Then during validation process, both of these constraints are checked and, in case the vocabulary constraint is not satisfied, an error message about the size constraint is reported to the user, which is misleading. It seems to me that the validation process for constraints should stop upon first error. | |
priority | normal |
---|---|
type | bug |
done in | 0.39.1 |
load | 0.500 |
load left | 0.000 |
closed by | #099fa63a02f0 Raise a ValidationError corresponding to the first unsatisfied constraint during entity validation |
patch | Raise a ValidationError corresponding to the first unsatisfied constraint during entity validation [applied] |
Comments
-
2014/01/16 10:07, written by jcristau
-
2014/01/16 10:25, written by dlaxalde
-
2014/01/16 10:35, written by dlaxalde
-
2014/01/16 10:42, written by jcristau
-
2014/01/16 10:52, written by dlaxalde
-
2014/01/16 10:59, written by acampeas
-
2014/01/16 12:16, written by dlaxalde
-
2014/03/31 08:21, written by jcristau
-
2014/03/31 09:33, written by dlaxalde
add commentI disagree. If there are errors while filling out a form you don't want to discover them one at a time, you want to be able to fix all of them.
It seems to me that the current implementation does not actually report all errors, but only the last one in the list.
More specifically, the current implementation reports errors for all attributes/relations, but for individual relations, only the last unsatisfied constraints is reported. So for individual relations, if we keep the idea of reporting errors one at a time, I think it makes more sense to start with the first one, not the last since automatically added constraint will be appended to the list.
sounds reasonable. so yams would keep reporting all errors, and then cubicweb would pick the one it wants, right?
if you put, e.g., a string for age and 'female' for gender, you'll get two errors (for both age and gender), but only one for gender whereas there are actually two unsatisfied constraints: the vocabulary constraint and the (automatically added) size constraint. I suggest to expose the first one first, currently, yams shows the last one first.
if that's related to this snippet in schema.py ~check method, then we'll need to impose an ordering on the constraints ?
That's another story I think. I'm only considering the case where the order is predictable (e.g. when running tests).
Hrm. Why did this get in? We go from one arbitrary behaviour to another arbitrary behaviour with a dubious justification, that doesn't sound like progress.
I would argue that there is at least a partial progress.