Removed text 'for dictionary value' from the validation message for dict#18
Removed text 'for dictionary value' from the validation message for dict#18rwieckowski wants to merge 1 commit intoalecthomas:masterfrom rwieckowski:dict-messages
Conversation
|
This text was explicitly chosen because without it the error message can be ambiguous, so I prefer not to merge as-is. I wouldn't be opposed to a Schema-level option to enable this behaviour, though there are a bunch more places that need to be changed to make this consistent. For example, list/tuple validators have the same form and would also need to be updated. Feel free to reopen this or send through another pull request if you continue. |
|
The problem is with dictionaries where returned message is concatenated with additional text. That text shows in my user-defined message, so I don't have full control on its final form. In case of list/tuples you doesn't have message concatenation so user-defined messages works fine here. import voluptuous as v
validate = v.Schema(['one'])
validate(['two'])gives us And with user-defined message import voluptuous as v
validate = v.Schema(v.msg(['one'], 'should be "one"'))
validate('two')gives us (which is correct) Also check example in the pull request which shows why the dictionary behaviours differently. |
This allows any validator to be compiled by implementing the __voluptuous_compile__ method. This avoids having voluptuous.Any and voluptuous.All defining new Schema for sub-validators: they can be compiled recursively using the same parent schema. This solves the recursive Self case. Fixes alecthomas#18
This allows any validator to be compiled by implementing the __voluptuous_compile__ method. This avoids having voluptuous.Any and voluptuous.All defining new Schema for sub-validators: they can be compiled recursively using the same parent schema. This solves the recursive Self case. Fixes alecthomas#18
* Allow to use nested schema This allows to refer to the current schema using voluptuous.Self and have nested definitions. Fixes #128 * Allow any validator to be compiled This allows any validator to be compiled by implementing the __voluptuous_compile__ method. This avoids having voluptuous.Any and voluptuous.All defining new Schema for sub-validators: they can be compiled recursively using the same parent schema. This solves the recursive Self case. Fixes #18
Removed additional text for messages created during dictionary validation to provide consistent messages with other schema types and clean user defined messages.
Now the user defined messages are not polluted with additional text.
Following code:
gives us
instead of