schema
schema copied to clipboard
How to customize the error information for each field in JSON?
How to customize the error information for each field in JSON? For example, the "name" field is required. If I don't transmit this field, I want to prompt my own customized error response information instead of the default error prompt. I see that there is an "error" parameter function, but it can only prompt for the whole JSON, not provide custom error information for each field in the JSON
Regex, Use, and Schema all allow error to be specified. If you want to specify a custom error for something simple, just wrap it in Schema.
Schema(bool, "This isn't a Boolean")
You can nest it in a larger schema.
Schema({'enabled': Schema(bool, "This isn't a Boolean")})