Beispiel #1
0
def validate_default_is_of_one_of_declared_types(default, type_, **kwargs):
    if isinstance(type_, six.string_types):
        type_ = [type_]

    if not is_value_of_any_type(default, type_):
        raise ValidationError(
            MESSAGES['default']['invalid_type'].format(default, type_), )
Beispiel #2
0
def validate_type(value, types, **kwargs):
    """
    Validate that the value is one of the provided primative types.
    """
    if not is_value_of_any_type(value, types):
        raise ValidationError(MESSAGES['type']['invalid'].format(
            repr(value), get_type_for_value(value), types,
        ))
Beispiel #3
0
def validate_type(value, types, **kwargs):
    """
    Validate that the value is one of the provided primative types.
    """
    if not is_value_of_any_type(value, types):
        raise ValidationError(MESSAGES['type']['invalid'].format(
            repr(value), get_type_for_value(value), types,
        ))
Beispiel #4
0
def validate_default_is_of_one_of_declared_types(default, type_, **kwargs):
    if isinstance(type_, six.string_types):
        type_ = [type_]

    if not is_value_of_any_type(default, type_):
        raise ValidationError(
            MESSAGES['default']['invalid_type'].format(default, type_),
        )
Beispiel #5
0
            def inner(value, *args, **kwargs):
                """
                Format validation should only be executed if the value is of
                one of the appropriate types for the format.

                http://json-schema.org/latest/json-schema-validation.html#anchor105
                """
                if is_value_of_any_type(value, types):
                    return func(value, *args, **kwargs)
Beispiel #6
0
            def inner(value, *args, **kwargs):
                """
                Format validation should only be executed if the value is of
                one of the appropriate types for the format.

                http://json-schema.org/latest/json-schema-validation.html#anchor105
                """
                if is_value_of_any_type(value, types):
                    return func(value, *args, **kwargs)
Beispiel #7
0
 def inner(value, *args, **kwargs):
     if value is EMPTY or is_value_of_any_type(value, types):
         return func(value, *args, **kwargs)
Beispiel #8
0
 def from_native(self, data, files=None):
     if not is_value_of_any_type(data, (ARRAY, OBJECT, STRING)):
         raise serializers.ValidationError(
             self.error_messages['invalid_type_for_items']
         )
     return super(BaseItemsSerializer, self).from_native(data, files)
Beispiel #9
0
 def inner(value, *args, **kwargs):
     if value is EMPTY or is_value_of_any_type(value, types):
         return func(value, *args, **kwargs)