Ejemplo n.º 1
0
def validate_type_for_max_length(type_, maxLength, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((STRING,)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_max_length'],
        )
Ejemplo n.º 2
0
def validate_type_for_min_properties(type_, minProperties, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((OBJECT,)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_min_properties'],
        )
Ejemplo n.º 3
0
def validate_type_for_multiple_of(type_, multipleOf, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((INTEGER, NUMBER)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_multiple_of'],
        )
Ejemplo n.º 4
0
def validate_type_for_min_length(type_, minLength, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((STRING,)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_min_length'],
        )
Ejemplo n.º 5
0
def validate_type_for_unique_items(type_, uniqueItems, **kwargs):
    types = pluralize(type_)

    if not uniqueItems:
        return

    if not set(types).intersection((ARRAY,)):
        raise ValidationError(MESSAGES["type"]["invalid_type_for_unique_items"])
Ejemplo n.º 6
0
def validate_types(type_, **kwargs):
    types = pluralize(type_)

    with ErrorList() as errors:
        for value in types:
            try:
                single_type_validator(value)
            except ValidationError as err:
                errors.add_error(err.detail)
Ejemplo n.º 7
0
Archivo: type.py Proyecto: Arable/flex
def validate_types(type_, **kwargs):
    types = pluralize(type_)

    with ErrorList() as errors:
        for value in types:
            try:
                single_type_validator(value)
            except ValidationError as err:
                errors.add_error(err.detail)
Ejemplo n.º 8
0
def validate_type_for_unique_items(type_, uniqueItems, **kwargs):
    types = pluralize(type_)

    if not uniqueItems:
        return

    if not set(types).intersection((ARRAY,)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_unique_items'],
        )
Ejemplo n.º 9
0
def validate_type_for_multiple_of(type_, multipleOf, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((INTEGER, NUMBER)):
        raise ValidationError(
            MESSAGES['type']['invalid_type_for_multiple_of'], )
Ejemplo n.º 10
0
def test_with_tuple():
    actual = pluralize(('a', ))
    assert actual == ('a', )
Ejemplo n.º 11
0
def test_with_null():
    actual = pluralize(None)
    assert actual == [None]
Ejemplo n.º 12
0
def test_with_list():
    actual = pluralize(['a'])
    assert actual == ['a']
Ejemplo n.º 13
0
def test_with_float():
    actual = pluralize(1.1)
    assert actual == [1.1]
Ejemplo n.º 14
0
def test_with_string():
    actual = pluralize('abc')
    assert actual == ['abc']
Ejemplo n.º 15
0
def test_with_dict():
    actual = pluralize({'a': 1})
    assert actual == [{'a': 1}]
Ejemplo n.º 16
0
def test_with_tuple():
    actual = pluralize(('a',))
    assert actual == ('a',)
Ejemplo n.º 17
0
def test_with_null():
    actual = pluralize(None)
    assert actual == [None]
Ejemplo n.º 18
0
def test_with_list():
    actual = pluralize(['a'])
    assert actual == ['a']
Ejemplo n.º 19
0
Archivo: items.py Proyecto: Arable/flex
def validate_items_required_if_array_type(type_, items, **kwargs):
    types = pluralize(type_)

    if ARRAY in types and items is EMPTY:
        raise ValidationError(MESSAGES['items']['items_required_for_type_array'])
Ejemplo n.º 20
0
def test_with_dict():
    actual = pluralize({'a': 1})
    assert actual == [{'a': 1}]
Ejemplo n.º 21
0
def test_with_string():
    actual = pluralize('abc')
    assert actual == ['abc']
Ejemplo n.º 22
0
def test_with_integer():
    actual = pluralize(1)
    assert actual == [1]
Ejemplo n.º 23
0
def validate_items_required_if_type_arraw(type_, items, **kwargs):
    types = pluralize(type_)
    if ARRAY in types and items is EMPTY:
        raise ValidationError(MESSAGES['required']['required'])
Ejemplo n.º 24
0
def test_with_integer():
    actual = pluralize(1)
    assert actual == [1]
Ejemplo n.º 25
0
def validate_type_for_minimum(type_, minimum, **kwargs):
    types = pluralize(type_)

    if not set(types).intersection((INTEGER, NUMBER)):
        raise ValidationError(MESSAGES["type"]["invalid_type_for_minimum"])
Ejemplo n.º 26
0
def test_with_float():
    actual = pluralize(1.1)
    assert actual == [1.1]