Skip to content

Commit

Permalink
merge in main
Browse files Browse the repository at this point in the history
  • Loading branch information
keithasaurus committed Aug 19, 2024
2 parents 6147091 + e87258a commit c0d5776
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
4.1.1 (Apr 9, 2024)
**Optimization**
- Use `pattern.match(...)` instead of `re.match(pattern, ...)` in `RegexPredicate` and `EmailPredicate`

4.1.0 (Feb 29, 2024)
**Features**
- `ValidationResult.map()` can be used to succinctly convert data contained within `Valid` objects to some other type or value
Expand Down
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 c0d5776

Please sign in to comment.