示例#1
0
文件: max_length.py 项目: Arable/flex
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'],
        )
示例#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'],
        )
示例#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'],
        )
示例#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'],
        )
示例#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"])
示例#6
0
文件: type.py 项目: djta/5GCORE-1
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)
示例#7
0
文件: type.py 项目: 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)
示例#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'],
        )
示例#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'], )
示例#10
0
def test_with_tuple():
    actual = pluralize(('a', ))
    assert actual == ('a', )
示例#11
0
def test_with_null():
    actual = pluralize(None)
    assert actual == [None]
示例#12
0
def test_with_list():
    actual = pluralize(['a'])
    assert actual == ['a']
示例#13
0
def test_with_float():
    actual = pluralize(1.1)
    assert actual == [1.1]
示例#14
0
def test_with_string():
    actual = pluralize('abc')
    assert actual == ['abc']
示例#15
0
def test_with_dict():
    actual = pluralize({'a': 1})
    assert actual == [{'a': 1}]
示例#16
0
def test_with_tuple():
    actual = pluralize(('a',))
    assert actual == ('a',)
示例#17
0
def test_with_null():
    actual = pluralize(None)
    assert actual == [None]
示例#18
0
def test_with_list():
    actual = pluralize(['a'])
    assert actual == ['a']
示例#19
0
文件: items.py 项目: 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'])
示例#20
0
def test_with_dict():
    actual = pluralize({'a': 1})
    assert actual == [{'a': 1}]
示例#21
0
def test_with_string():
    actual = pluralize('abc')
    assert actual == ['abc']
示例#22
0
def test_with_integer():
    actual = pluralize(1)
    assert actual == [1]
示例#23
0
文件: __init__.py 项目: djta/5GCORE-1
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'])
示例#24
0
def test_with_integer():
    actual = pluralize(1)
    assert actual == [1]
示例#25
0
文件: minimum.py 项目: Arable/flex
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"])
示例#26
0
def test_with_float():
    actual = pluralize(1.1)
    assert actual == [1.1]