Пример #1
0
 def __post_init__(self):
     validate_dataclass(self)
     validate('MenuDescription.value',
              self.value,
              min_len=1,
              max_len=1000,
              custom=pattern(r'[0-9A-Za-z ;.,_-]*'))
Пример #2
0
 def __post_init__(self):
     validate_dataclass(self)
     validate('Key.value',
              self.value,
              min_len=1,
              max_len=10,
              custom=pattern(r'[0-9A-Za-z_-]*'))
Пример #3
0
def test_validate_dataclass():
    @dataclass()
    class Foo:
        bar: str

    validate_dataclass(Foo('ok'))
    with pytest.raises(TypeError):
        validate_dataclass(Foo(1))
Пример #4
0
 def __post_init__(self, create_key: Any):
     validate('create_key', create_key, custom=Menu.Builder.is_valid_key)
     validate_dataclass(self)
Пример #5
0
 def __post_init__(self):
     validate_dataclass(self)
Пример #6
0
 def __post_init__(self, ):
     validate_dataclass(self)
     validate('category', self.value, min_value=0, max_value=3)
Пример #7
0
 def __post_init__(self, ):
     validate_dataclass(self)
     validate('location',
              self.value,
              max_len=50,
              custom=pattern(r'^[a-zA-Z0-9 ]+$'))
Пример #8
0
 def __post_init__(self):
     validate_dataclass(self)
     validate('date', self.date, min_value=datetime.now())
Пример #9
0
 def __post_init__(self):
     validate_dataclass(self)
     validate('key', self.key)
Пример #10
0
 def __post_init__(self, ):
     validate_dataclass(self)
     validate('date', self.end_date, min_value=self.start_date)
Пример #11
0
 def __post_init__(self, ):
     validate_dataclass(self)
     validate('priority', self.value, min_value=0, max_value=2)