예제 #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)