Skip to content

Commit

Permalink
use pattern method on regex
Browse files Browse the repository at this point in the history
  • Loading branch information
keithasaurus committed Mar 4, 2024
1 parent 0703958 commit 44119f3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions koda_validate/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ class RegexPredicate(Predicate[str]):
pattern: Pattern[str]

def __call__(self, val: str) -> bool:
return re.match(self.pattern, val) is not None
return self.pattern.match(val) is not None


@dataclass
class EmailPredicate(Predicate[str]):
pattern: Pattern[str] = re.compile("[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+")

def __call__(self, val: str) -> bool:
return re.match(self.pattern, val) is not None
return self.pattern.match(val) is not None

0 comments on commit 44119f3

Please sign in to comment.