Exemplo n.º 1
0
class Example(Structure):
    _required = []
    #set support, similar to Array
    b = Set(minItems=3, maxItems=5, items=Number(maximum=10))
    d = Set(minItems=2, items=String)
    e = Set(minItems=2)
    f = Set[Integer]
    g = Set[AnyOf(fields=[String(minLength=3), Number(minimum=10)])]
Exemplo n.º 2
0
class Person(Structure):
    _required = ['ssid']
    name = String(pattern='[A-Za-z]+$', maxLength=8)
    ssid = String(minLength=3, pattern='[A-Za-z]+$')
    num = Integer(maximum=30,
                  minimum=10,
                  multiplesOf="dd",
                  exclusiveMaximum=False)
    foo = StructureReference(a=String(),
                             b=StructureReference(c=Number(minimum=10),
                                                  d=Number(maximum=10)))
Exemplo n.º 3
0
class Example(Structure):
    i = Integer(maximum=10)
    s = String(maxLength=5)
    a = Array[Integer(multiplesOf=5), Number]
    foo = StructureReference(a1=Integer(), a2=Float())
    ss = SimpleStruct
    all = AllOf[Number, Integer]
    any = AnyOf[Number(minimum=1), Integer]
    one = OneOf[Number(minimum=1), Integer]
    no = NotField(fields=[String])
    enum = Enum(values=[1, 2, 3])
Exemplo n.º 4
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]]
Exemplo n.º 5
0
class Example(Structure):
    _additionalProperties = True
    _required = []
    # deque support, similar to json schema
    a = Deque(uniqueItems=True,
              minItems=3,
              items=[String(), Number(maximum=10)])
    b = Deque(minItems=3, maxItems=5, items=Number(maximum=10))
    c = Deque(items=[String(), String(), Number(maximum=10)])
    d = Deque(minItems=2, items='')
    e = Deque(minItems=2)
    f = Deque[Integer]
    g = Deque[Foo]
    h = Deque[Deque[Integer]]
    i = ImmutableDeque[String]
Exemplo n.º 6
0
class Example(Structure):
    _additionalProperties = True
    _required = []
    #array support, similar to json schema
    a = Tuple(uniqueItems=True, items=[String, String])
    b = Tuple(items=[String, String, Number(maximum=10)])
    c = Tuple[Integer, String, Float]
Exemplo n.º 7
0
class Example(Structure):
    _additionalProperties = True
    _required = []
    a = AllOf(
        [Number(multiplesOf=5, maximum=20, minimum=-10), Integer, Positive])
    # Can also omit the parens
    b = AnyOf[Number(maximum=20, minimum=-10), Integer(), Positive, String]
    c = OneOf([
        Number(multiplesOf=5, maximum=20, minimum=-10), Integer, Positive,
        String
    ])
    d = NotField([Number(multiplesOf=5, maximum=20, minimum=-10), String])
    e = AllOf([])
    broken = AllOf[String, Integer]
    f = NotField[Number]
    g = AnyOf[Foo, Integer]
Exemplo n.º 8
0
class Example(Structure):
    _required = []

    # standard definition: limits on size. key is a number<=10, value is a string
    a = Map(minItems=3, maxItems=5, items=[Number(maximum=10), String()])

    # a slightly simplified representation - not that String has no '()'
    b = Map(items=(Number(maximum=10), String))

    # Limits on size. Key and value can be anything
    c = Map(minItems=3, maxItems=5)

    # terse, Java-generics like: Key is String of size>=3, value is a number
    d = Map[String(minLength=3), Number]

    # terse, Java-generics like, representation: Key is string, value is a number
    e = Map[String, Number]

    #Key is string, value can be anything
    f = Map[String, Field]
Exemplo n.º 9
0
class C(Structure):
    x = Number(immutable=False)
 class Example(Structure):
     a = AllOf[Number(minimum=10), float]