vcti-predicate
VCollab Predicate - condition evaluation engine with extensible operators and modifiers
Overview
Filtering, validation, rule engines and routing logic all need to answer
one question: does this value satisfy this condition? vcti-predicate
answers it with two entry points, check() and evaluate(). A condition
is an op string ("==", "^=", "between", "is_file") that names a
test, applied to one or more arguments, with modifiers such as
case_sensitive or tolerance. The type of the first argument selects the
implementation, so one rule works across strings, numbers, paths and
None. Every op string can be negated with a leading !, and the built-in
symbols can be extended by building your own registry.
Installation
pip install vcti-predicate
In requirements.txt
vcti-predicate>=3.0.1
In pyproject.toml dependencies
dependencies = [
"vcti-predicate>=3.0.1",
]
Quick Start
from vcti.predicate import check, evaluate
# ── Binary: check(lhs, op_string, rhs) ──
check("Hello", "==", "hello") # True: case-insensitive by default
check("Hello", "==", "hello", case_sensitive=True) # False
check(1.0, "==", 1.001, tolerance=0.01) # True
check(5, "between", (1, 10)) # True: bounds in either order
check("filename.pdf", "$=", ".PDF") # True: ends with
check("Hello", "^=cs", "he") # False: the cs variant is case-sensitive
check("test123", "~=", r"\d+$") # True: regex search
check(["Wing", "Tail"], "?=", "wing") # True: contains
# ── Negation: "!" before any op string ──
check("hello", "!^=", "xyz") # True
check(0, "!between", (1, 10)) # True
# ── Unary: check(value, op_string) ──
check("", "is_empty") # True
check(None, "exists") # False
check("12", "is_numeric", numeric_strings=True) # True
check(".", "is_dir") # True
# ── Prefix form, for rules held as data ──
rule = ("^=", "wing")
evaluate(rule[0], "Wing_01", rule[1]) # True
Strings and numbers are not mixed unless asked: check(5, "==", "5") is
False, and check(5, "==", "5", numeric_strings=True) is True.
Entry Points
| Function | Argument order | Use case |
|---|---|---|
check(value, op_string, /, **modifiers) |
value first | A unary test, written as code reads |
check(lhs, op_string, rhs, /, **modifiers) |
value first | A binary test |
evaluate(op_string, /, *args, **modifiers) |
op string first | Rules held as data, any number of arguments |
Both run the same pipeline: parse the op string, select the operator by the
type of the first argument, prepare the arguments and modifiers, and run
the test. builtin_registry holds the built-in symbols, and check and
evaluate are its methods. A custom Registry has the same methods.
Symbol Summary
| Family | Op strings | Modifiers |
|---|---|---|
| Comparison | == eq, < lt, <= le, > gt, >= ge, between; != and ne negate == |
case_sensitive, tolerance, inclusive, allow_nan, numeric_strings |
| String matching | ^= startswith, $= endswith, ~= matches, each with cs and ic variants (^=cs) |
case_sensitive, multiline, dotall |
| Collection items | ?= contains has, ?=cs, ?=ic |
case_sensitive, tolerance, allow_nan, numeric_strings |
| Value checks | is_empty, exists, is_numeric |
numeric_strings |
| Path checks | is_file, is_dir, path_exists |
none |
Every op string has a negated form with a leading !: !^=cs, !?=,
!is_file. The enum Symbol names each symbol (Symbol.STARTS_WITH) for
code that should not type strings. The full reference, with what each
symbol does for each type, is docs/symbols.md.
Modifiers
| Modifier | Default | Effect |
|---|---|---|
case_sensitive |
False |
Compare strings without casefolding |
tolerance |
0 |
Numbers within this absolute difference are equal, also for ordering |
inclusive |
True |
between includes its bounds |
allow_nan |
False |
Accept nan and apply IEEE rules; by default a nan raises |
numeric_strings |
False |
Let a string stand in for a number, and a number for a string |
multiline, dotall |
False |
re.MULTILINE / re.DOTALL for ~= |
A modifier outside the symbol's family raises ModifierError, which
catches typos such as tolernce. A modifier of the family that the
selected operator does not use is ignored, so one rule works on values of
different types: tolerance matters for numbers and not for strings.
These modifiers are the fields of BuiltinModifiers, the built-in
registry's modifiers class; a custom registry can subclass it to add its
own (see the extension guide).
Errors
Every error derives from PredicateError and reports the local failure,
with the op string as written (error.op_string):
| Error | Raised when |
|---|---|
UnknownSymbolError |
The op string is not known |
NoOperatorError |
The symbol has no operator for the value's type (None with "^=") |
ArityError |
The number of arguments is wrong |
ModifierError |
A modifier is unknown, invalid, or disagrees with the op string |
OperandError |
An argument is not accepted (5 < "6", a nan, bounds that are not a pair) |
NormalizationError |
An accepted argument cannot be prepared (an invalid regex) |
PreparationError |
The base of the three above, and an unexpected failure while preparing |
EvaluationError |
The test itself failed (permission denied on is_file) |
What an error means is for the caller to decide: a filter can treat
NoOperatorError as "no match" and report every other error as a broken
rule.
Dependencies
None. vcti-predicate uses only the Python standard library.
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| Look up every symbol and what it does for each type | docs/symbols.md |
| See practical, real-world usage | docs/patterns.md |
| Understand the architecture and design decisions | docs/design.md |
| Move code from 2.x to 3.0 | docs/migration-3.0.md |
| Navigate and understand the source | docs/source-guide.md |
| Add symbols, groups and operators | docs/extending.md |
Metadata
Release files for vcti-predicate 3.0.1
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 | Actions |
|---|---|---|---|---|
| vcti_predicate-3.0.1.tar.gz | 61.3 kB | With provenance | Details for vcti_predicate-3.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vcti_predicate-3.0.1-py3-none-any.whl | Python 3 | none | any | Details for vcti_predicate-3.0.1-py3-none-any.whl |
Total release size: 96.9 kB
Release files / vcti_predicate-3.0.1.tar.gz
| Download URL | vcti_predicate-3.0.1.tar.gz |
|---|---|
| Size | 61.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9049f9d3d1bd443397c6afb7ead0c31e04ffeadc3d9011a870703e1497b635bf
|
|
BLAKE2b-256 checksum How to use checksums |
e67b5d27ca6654cbd9b4e5845029af889a5a17d4e312ab75f8e31da9dc20eebf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / vcti_predicate-3.0.1-py3-none-any.whl
| Download URL | vcti_predicate-3.0.1-py3-none-any.whl |
|---|---|
| Size | 35.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca4b7d3d7068d3f2d4e592c663c72ad262ea04deee60a62c02439f73ff45d646
|
|
BLAKE2b-256 checksum How to use checksums |
986f68a8c860eef2627f7cf57563341b45a661c15e0e0d9325631e9b39705bee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for vcti-predicate 3.0.1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for vcti_predicate-3.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.