Currently, we give badly worded messages when validations fail, such as
Is x a string failed for ....
I propose using string.Formatter to generate messages that are easier for humans to parse. For example:
@validator_msg("Expected {name} to be a list, got {type} instead")
def _is_list(x):
pass
@validator_msg("Expected {name} to be a valid ISO8601(YYYY-mm-dd) date format")
def _is_date(x):
pass
@validator_msg("Is x an old validator msg")
def _yes(x):
pass
string.Formatter can check how many fields there are. If 0, then it can format the message as before. Otherwise we can try to subsitute name and type (and maybe others) with relevant data.
Currently, we give badly worded messages when validations fail, such as
Is x a string failed for ...
.I propose using
string.Formatter
to generate messages that are easier for humans to parse. For example:string.Formatter
can check how many fields there are. If 0, then it can format the message as before. Otherwise we can try to subsitutename
andtype
(and maybe others) with relevant data.