Skip to main content

The Criteria Pattern is a Python package that simplifies and standardizes criteria based filtering, validation and selection.

Project description

🤏🏻 Criteria Pattern

CI Pipeline Coverage Pipeline Package Version Supported Python Versions Package Downloads Project Documentation

The Criteria Pattern is a Python 🐍 package that simplifies and standardizes criteria based filtering 🤏🏻, validation and selection. This package provides a set of prebuilt 👷🏻 objects and utilities that you can drop into your existing projects and not have to implement yourself.

These utilities 🛠️ are useful when you need complex filtering logic. It also enforces 👮🏻 best practices so all your filtering processes follow a uniform standard.

Easy to install and integrate, this is a must have for any Python developer looking to simplify their workflow, enforce design patterns and use the full power of modern ORMs and SQL 🗄️ in their projects 🚀.

Table of Contents

🔼 Back to top



📥 Installation

You can install Criteria Pattern using pip:

pip install criteria-pattern

🔼 Back to top



📚 Documentation

This project's documentation is powered by DeepWiki, which provides a comprehensive overview of the Criteria Pattern and its usage.

🔼 Back to top



💻 Utilization

from criteria_pattern import Criteria, Filter, Operator
from criteria_pattern.converter import SqlConverter

is_adult = Criteria(filters=[Filter(field='age', operator=Operator.GREATER_OR_EQUAL, value=18)])
email_is_gmail = Criteria(filters=[Filter(field='email', operator=Operator.ENDS_WITH, value='@gmail.com')])
email_is_yahoo = Criteria(filters=[Filter(field='email', operator=Operator.ENDS_WITH, value='@yahoo.com')])

query, parameters = SqlConverter.convert(criteria=is_adult & (email_is_gmail | email_is_yahoo), table='user')
print(query)
print(parameters)
# >>> SELECT * FROM user WHERE (age >= %(parameter_0)s AND (email LIKE '%%' || %(parameter_1)s OR email LIKE '%%' || %(parameter_2)s));
# >>> {'parameter_0': 18, 'parameter_1': '@gmail.com', 'parameter_2': '@yahoo.com'}

🔼 Back to top



🤝 Contributing

We love community help! Before you open an issue or pull request, please read:

Thank you for helping make 🤏🏻 Criteria Pattern package awesome! 🌟

🔼 Back to top



🔑 License

This project is licensed under the terms of the MIT license.

🔼 Back to top

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

criteria_pattern-1.3.0.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

criteria_pattern-1.3.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file criteria_pattern-1.3.0.tar.gz.

File metadata

  • Download URL: criteria_pattern-1.3.0.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for criteria_pattern-1.3.0.tar.gz
Algorithm Hash digest
SHA256 2342efa21fcfde93a5f0e15503157746ce3a48706be46b8fc6b1117b4b9804ff
MD5 4472b1f5c99534a1000691fdc25c28eb
BLAKE2b-256 be0a5b74abdadee1c813ea38699c7d73ae99de69d34b49d9d0f86573f16fc47e

See more details on using hashes here.

Provenance

The following attestation bundles were made for criteria_pattern-1.3.0.tar.gz:

Publisher: ci.yaml on adriamontoto/criteria-pattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file criteria_pattern-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for criteria_pattern-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7e03fc4644e4ab2aadc13daa610c9872a348c4796d610484fb1f0ae53e451aea
MD5 1688f4bf7077d777c4cdbd9de6b5a331
BLAKE2b-256 eab6e08a1dfd15c23e0de7b1e9a4e80436de6156aea9ecc9ba941ecaa478a27c

See more details on using hashes here.

Provenance

The following attestation bundles were made for criteria_pattern-1.3.0-py3-none-any.whl:

Publisher: ci.yaml on adriamontoto/criteria-pattern

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page