Пример #1
0
class Example(Structure):
    _additionalProperties = True
    _required = []
    # array support, similar to json schema
    a = Array(uniqueItems=True,
              minItems=3,
              items=[String(), Number(maximum=10)])
    b = Array(minItems=3, maxItems=5, items=Number(maximum=10))
    c = Array(items=[String(), String(), Number(maximum=10)])
    d = Array(minItems=2, items='')
    e = Array(minItems=2)
    f = Array[Integer]
    g = Array[Foo]
    h = Array[Array[Integer]]
Пример #2
0
class Example(Structure):
    _required = []
    a = Integer
    b = String
    c = Array[String(minLength=3, pattern='[A-Za-z]+$')]
    d = Array[Integer]
    e = Array[Integer, String]
    f = Array(items=[String, Integer])
Пример #3
0
class Foo(Structure):
    a = DecimalNumber
    b = DecimalNumber(maximum=100, multiplesOf=5)
    c = PositiveDecimal
    d = DateField
    arr = Array(items=String, minItems=1)
    _optional = ["d"]
    _additionalProperties = False
Пример #4
0
 class Foo(Structure):
     a = Array(items=Integer())
Пример #5
0
 class A(Structure):
     arr = Array(items=PositiveEnum(values=[23, -5, 12, 5]))
Пример #6
0
 class Foo(Structure):
     a = Array(items=[int])
Пример #7
0
 class Bar(Structure):
     foos = Array(minItems=1, items=Foo)
Пример #8
0
 class Foo(Structure):
     arr = Array(minItems=2)
Пример #9
0
 class Foo(Structure):
     arr = Array(minItems=2)
     _required = ['arr']
     _additionalProperties = False
Пример #10
0
 class Foo(Structure):
     a = Array(minItems=3)
Пример #11
0
 class Foo(Structure):
     bars = Array(items=Bar)
Пример #12
0
 class Foo(Structure):
     bars = Array(items=[Bar, Bar])
 def Names():
     return Array(items=String(minLength=2))
Пример #14
0
def test_invalid_defaults_raise_error3():
    with pytest.raises(ValueError) as excinfo:
        Array(minItems=3, default=[1])
    assert "Invalid default value: [1]" in str(excinfo.value)