MCPcopy Create free account
hub / github.com/tortoise/tortoise-orm / RegexValidator

Class RegexValidator

tortoise/validators.py:23–33  ·  view source on GitHub ↗

A validator to validate the given value whether match regex or not.

Source from the content-addressed store, hash-verified

21
22
23class RegexValidator(Validator):
24 """
25 A validator to validate the given value whether match regex or not.
26 """
27
28 def __init__(self, pattern: str, flags: int | re.RegexFlag) -> None:
29 self.regex = re.compile(pattern, flags)
30
31 def __call__(self, value: Any) -> None:
32 if not self.regex.match(value):
33 raise ValidationError(f"Value '{value}' does not match regex '{self.regex.pattern}'")
34
35
36class MaxLengthValidator(Validator):

Callers 2

ValidatorModelClass · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…