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]]
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])
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
class Foo(Structure): a = Array(items=Integer())
class A(Structure): arr = Array(items=PositiveEnum(values=[23, -5, 12, 5]))
class Foo(Structure): a = Array(items=[int])
class Bar(Structure): foos = Array(minItems=1, items=Foo)
class Foo(Structure): arr = Array(minItems=2)
class Foo(Structure): arr = Array(minItems=2) _required = ['arr'] _additionalProperties = False
class Foo(Structure): a = Array(minItems=3)
class Foo(Structure): bars = Array(items=Bar)
class Foo(Structure): bars = Array(items=[Bar, Bar])
def Names(): return Array(items=String(minLength=2))
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)