Example #1
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_-]*'))
Example #2
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 ;.,_-]*'))
Example #3
0
def test_regex_for_int():
    assert pattern(r'\d+')('0')
    assert not pattern(r'\d+')('a')
Example #4
0
def test_regex_for_single_word():
    assert pattern(r'\w+')('abc')
    assert not pattern(r'\w+')('abc abc')
Example #5
0
 def __post_init__(self, ):
     validate_dataclass(self)
     validate('location',
              self.value,
              max_len=50,
              custom=pattern(r'^[a-zA-Z0-9 ]+$'))