Installation
pip install pydantic-logic
Examples
True expression
from pydantic_logic import Logic, LogicExpression, Operator
data = {
"Phone number": "123123123",
"some_value": True,
"some_other_value": 1,
}
logic = Logic(
expressions=[
LogicExpression.b("Phone number", Operator.NE, "adasdasdasd"),
LogicExpression.b("some_value", Operator.EQ, True),
LogicExpression.b("some_other_value", Operator.GT, 0),
]
)
assert logic.evaluate(data)
False expression
from pydantic_logic import Logic, LogicExpression, Operator
data = {
"Phone number": "123123123",
"some_value": True,
"some_other_value": 1,
}
logic = Logic(
expressions=[
LogicExpression.b("Phone number", Operator.EQ, "123123123"),
LogicExpression.b("some_value", Operator.NE, False),
LogicExpression.b("some_other_value", Operator.LT, 1),
]
)
assert not logic.evaluate(data)
Empty expression with default result
Suitable if the expressions are set by the end users, not the code
from pydantic_logic import Logic
data = {
"Phone number": "123123123",
"some_value": True,
"some_other_value": 1,
}
logic = Logic(
expressions=[]
)
assert logic.evaluate(data, default_if_empty=True)
Get wrong expressions
from pydantic_logic import Logic, LogicExpression, Operator
data = {
"Phone number": "123123123",
"some_value": True,
"some_other_value": 1,
}
logic = Logic(
expressions=[
LogicExpression.b("Phone number", Operator.EQ, "123123123"),
LogicExpression.b("some_value", Operator.NE, False),
LogicExpression.b("some_other_value", Operator.LT, 1),
]
)
logic.get_wrong_expressions(data) # second and third
Metadata
Release files for pydantic-logic 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pydantic_logic-1.0.3.tar.gz | 3.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_logic-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.2 kB
Release files / pydantic_logic-1.0.3.tar.gz
| Download URL | pydantic_logic-1.0.3.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d6238f5fa0dd8e6a14985324acc06cb0e1cc513cca462731c4d981acfe29445
|
|
BLAKE2b-256 checksum How to use checksums |
04d90cf570405e45573852ccdded25a9ff0be39c388208d0d1942079338ad6e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Release files / pydantic_logic-1.0.3-py3-none-any.whl
| Download URL | pydantic_logic-1.0.3-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17ea12645fc4235057a00345ffa5c69f86e18945b2094f891661cea9943a9a33
|
|
BLAKE2b-256 checksum How to use checksums |
b9e9de52d3c3197bd88c732893ef03ebd937b24541cea40a294e187fc0fa99ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.7 Linux/6.5.0-1025-azure
|
Security for pydantic-logic 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.