diff --git a/.github/parasite_logo.png b/.github/parasite_logo.png new file mode 100644 index 0000000..6098e06 Binary files /dev/null and b/.github/parasite_logo.png differ diff --git a/README.md b/README.md index 081e160..d0901b9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,28 @@ -# `parasite` - `zod` inspired library for Python 3.11+ - -> **DISCLAIMER:** +![Stars][stars-shield] +[![Contributors][contributors-shield]][contributors-url] +[![Forks][forks-shield]][forks-url] +[![Issues][issues-shield]][issues-url] +[![MIT License][license-shield]][license-url] + + +
+
+ + Logo + + +

parasite v0.1

+ +

+ zod inspired library for Python 3.11+ +
+ Report Bug + | + Request Feature +

+
+ +> [!WARNING] > > This library is under active development, expect things to break or not to work as expected. > Creating an issue for bugs you encounter would be appreciated. Documentation is currently work in @@ -54,7 +76,8 @@ parasite = "^0.1.0" ## Documentation -Work in Progress... +> [!IMPORTANT] +> Work in Progress... ## License (_MIT License_) @@ -76,4 +99,14 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. + +[license-shield]: https://img.shields.io/github/license/hendrikboeck/parasite?style=for-the-badge +[license-url]: https://github.com/hendrikboeck/parasite/blob/main/LICENSE +[issues-shield]: https://img.shields.io/github/issues/hendrikboeck/parasite?style=for-the-badge +[issues-url]: https://github.com/hendrikboeck/parasite/issues +[forks-shield]: https://img.shields.io/github/forks/hendrikboeck/parasite?style=for-the-badge +[forks-url]: https://github.com/hendrikboeck/parasite/forks +[contributors-shield]: https://img.shields.io/github/contributors/hendrikboeck/parasite?style=for-the-badge +[contributors-url]: https://github.com/hendrikboeck/parasite/contributors +[stars-shield]: https://img.shields.io/github/stars/hendrikboeck/parasite?style=for-the-badge diff --git a/pyproject.toml b/pyproject.toml index d92d970..626df3d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "parasite" -version = "0.1.1" +version = "0.1.2" description = "Data validation for Python 3" authors = ["Hendrik Boeck "] packages = [{ include = "*", from = "src" }] diff --git a/src/parasite/string.py b/src/parasite/string.py index 5df9ff3..fcfde42 100644 --- a/src/parasite/string.py +++ b/src/parasite/string.py @@ -333,6 +333,32 @@ def ipv6(self) -> String: self._m_regex_t = self._RegexType.IPV6 return self + def regex(self, value: Pattern) -> String: + """ + Sets the regex pattern to use for validation. + + Args: + value (Pattern): compiled regex pattern + + Returns: + String: modified instance + """ + self._m_regex_t = self._RegexType.REGEX + self._m_regex = value + return self + + def match(self, value: str) -> String: + """ + Sets the regex pattern to use for validation. + + Args: + value (str): regex pattern + + Returns: + String: modified instance + """ + return self.regex(re.compile(value)) + def _apply_transformations(self, value: str) -> str: """ Applies the transformations on the value.