예제 #1
0
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))
예제 #2
0
def parameter_immutable(key, value):
    if value:
        raise APIBadRequest(
            "Immutable Parameter: '{0}'. Remove '{0}' from your request.".
            format(key))
예제 #3
0
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))
예제 #4
0
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))
예제 #5
0
def type_boolean(key, value):
    if value and type(value) != bool:
        raise APIBadRequest(
            "Invalid parameter type: '{0}' must be a 'boolean'.".format(key))
예제 #6
0
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))
예제 #7
0
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))