Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pattern.match(...) instead of re.match(pattern, ...) in RegexPredicate and EmailPredicate #42

Merged
merged 4 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
project = "Koda Validate"
copyright = "2023, Keith Philpott"
author = "Keith Philpott"
release = "4.1.0"
release = "4.1.1"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "koda-validate"
version = "4.1.0"
version = "4.1.1"
readme = "README.md"
description = "Typesafe, composable validation"
documentation = "https://koda-validate.readthedocs.io/en/stable/"
Expand Down
Loading