tcrudge.utils package

tcrudge.utils.json module


JSON serializer for objects not serializable by default json code.

Parameters:obj (date, datetime or UUID) – object to serialize
Returns:formatted and serialized object
Return type:str

tcrudge.utils.validation module

Module for common validation tools.


Works for GET requests only

Validates the request’s GET method to define if there are X-Limit and X-Offset headers to extract them and concat with handler directly

tcrudge.utils.validation.validate_integer(val, min_value=None, max_value=None, default=None)

Validates the input val parameter.

If it is can not be converted to integer, returns default_value.

If it is less than min_value, returns min_value.

If it is greater than max_value, returns max_value.

  • val (int, float, digital string) – number to validate
  • min_value (int) – min value of validation range
  • max_value (int) – max value of validation range
  • default (int) – default value to return in case of exception

None, min, max, default or result - int

Return type:

NoneType, int