def type_string(key, value): if value and type(value) not in (str, unicode): raise APIBadRequest( "Invalid parameter type: '{0}' must be 'string' or 'unicode'.". format(key))
def parameter_immutable(key, value): if value: raise APIBadRequest( "Immutable Parameter: '{0}'. Remove '{0}' from your request.". format(key))
def array_length(key, array, threshold_value): if array and len(array) > threshold_value: raise APIBadRequest( "Invalid length: '{0}' must be less than {1} elements.".format( key, threshold_value))
def string_length(key, string, threshold_value): if string and len(string) > threshold_value: raise APIBadRequest( "Invalid length: '{0}' must be less than {1} characters.".format( key, threshold_value))
def type_boolean(key, value): if value and type(value) != bool: raise APIBadRequest( "Invalid parameter type: '{0}' must be a 'boolean'.".format(key))
def type_array(key, value): if value and type(value) not in (list, str): raise APIBadRequest( "Invalid parameter type: '{0}' must be an Array.".format(key))
def type_number(key, value): if value and type(value) not in (int, float): raise APIBadRequest( "Invalid parameter type: '{0}' must be 'integer' or 'float'.". format(key))