Filtered Parser

API-Reference: wsgi_tools.filtered_parser()

This includes the WSGI-app wsgi_tools.filtered_parser.FilteredJSONParser(). It is structured like the wsgi_tools.parser.JSONParser() described here, but does not accept every json-string.

What json-strings to accept is configured in filters.

A filter is a callable, which has the value to control as an arg and returns a tuple of the boolean, which tells you if this value is allowed and the reason as a string. If the value is allowed, the reason is not relevant and can be an empty string or None.

There are the premade filters wsgi_tools.filtered_parser.Int(), wsgi_tools.filtered_parser.Float(), wsgi_tools.filtered_parser.Boolean(), wsgi_tools.filtered_parser.Object(), wsgi_tools.filtered_parser.String(), wsgi_tools.filtered_parser.Options() and wsgi_tools.filtered_parser.List().