Skip to main content

vcti-predicate

VCollab Predicate - condition evaluation engine with extensible operators and modifiers

Overview

Filtering, validation, workflow conditionals and routing logic all need to evaluate conditions such as "is this value greater than X?", "does this string contain Y?" or "is Z in this list?". vcti-predicate provides two entry points, check() and evaluate(), that take a symbol ("==", "^=", "is_empty") and pick the comparison by the type of the left-hand operand. Each operator belongs to a group that normalizes its operands (strings compare case-insensitively by default) and declares the modifiers it accepts (case_sensitive, tolerance, inclusive). Symbols, operators and groups live in a registry you can extend or copy.


Installation

pip install vcti-predicate

In requirements.txt

vcti-predicate>=2.2.0

In pyproject.toml dependencies

dependencies = [
    "vcti-predicate>=2.2.0",
]

Quick Start

from vcti.predicate import check

# ── Binary: check(lhs, symbol, rhs) ──

# String (case-insensitive by default)
check("Hello", "==", "hello")         # True
check("filename.pdf", "$=", "pdf")    # True
check("filename", "?=", "name")       # True

# Integer (exact)
check(5, ">", 3)     # True
check(5, "==", 5)    # True

# Float (with tolerance)
check(1.0, "==", 1.001, tolerance=0.01)   # True

# Case-sensitive via modifier or suffix
check("Hello", "==", "hello", case_sensitive=True)  # False
check("Hello", "^=cs", "Hello")                     # True

# Collection operations
check(2, "@=", [1, 2, 3])                  # True
check(["a", "b"], "all", ["a", "b", "c"])  # True

# Regex matching with options
check("test123", "~=", r"\d+")                          # True
check("line1\nline2", "~=", r"^line2", multiline=True)  # True

# Negation
check("hello", "!^=", "xyz")    # True (does not start with)
check("hello", "!~=", r"\d+")   # True (no digits)
check(4, "!@=", [1, 2, 3])     # True (not in list)

# Range (rhs is a (lo, hi) pair: tuple, list, or any two-element iterable)
check(5, "between", (1, 10))       # True
check(0, "!between", (1, 10))      # True

# ── Unary: check(value, symbol) ──

check("", "is_empty")           # True
check(None, "exists")           # False
check("/tmp/f.txt", "is_file")  # True (if file exists)
check("/tmp", "is_dir")         # True (if directory exists)

Entry Points

Function Argument order Use case
check(lhs, op, rhs?) Value-first Primary user-facing function — binary and unary
evaluate(op, lhs, rhs?) Symbol-first For rule engines and programmatic use

Both use the same resolution, normalization, and dispatch engine.


Symbol Summary

Comparison

Symbol Alias Description
== eq Equal
!= ne Not equal
< <= > >= lt le gt ge Ordering

String

Symbol Alias Negation Description
^= startswith !^= Starts with
$= endswith !$= Ends with
?= contains !?= Contains
@= in !@= In collection/string

Regex

Symbol Alias Negation Description
~= matches !~= Regex search

Unary

Symbol Description
is_empty / exists / is_numeric Value checks
is_file / is_dir / path_exists Filesystem checks

Range

Symbol Description
between / !between Value within bounds (rhs is a (lo, hi) pair)

Modifier Suffixes

Append cs or ic to string symbols for case control: ^=cs, $=ic, ?=cs, @=ic, ~=cs. A suffix fixes the case handling, so it cannot be combined with the case_sensitive modifier.

For the complete symbol reference, see the Symbol Reference.


Modifiers

Pass modifiers as keyword arguments to control behavior:

check("Hello", "==", "hello", case_sensitive=True)   # False
check(1.0, "==", 1.001, tolerance=0.01)              # True
check(5, "between", (1, 10), inclusive=False)         # True
check("text", "~=", r"^line", multiline=True)        # regex option
Modifier Type Groups Default Effect
case_sensitive bool string, collection, regex False Case-sensitive comparison
tolerance float (int accepted) float 0.0 Maximum absolute difference for equality (float LHS only; finite, >= 0)
inclusive bool range True Include bounds in range check
multiline, dotall bool regex operators (options) False re.MULTILINE / re.DOTALL

Values are checked against the declared type, so case_sensitive="false" raises TypeError instead of being read as true. Types no group handles (lists, None, dates, ...) compare with plain Python operators and accept no modifiers.


Errors

check() and evaluate() raise NotApplicableError when the condition does not apply to a value of this type; the same condition works for another type. It has two subclasses:

  • UnsupportedOperandError: the symbol has no operator for the value's type (None with "^=").
  • InapplicableArgumentError: a keyword another operator of the symbol accepts, but not the one this type resolved to (None with "==" and case_sensitive=True).

A condition that is wrong raises UnknownSymbolError, ArityError, InvalidArgumentError (including a keyword no operator of the symbol accepts) or ArgumentTypeError; none of these means "does not apply". A keyword's type is checked even where it does not apply, but a range checked inside the operator that accepts it is not: for None, tolerance=-1 raises InapplicableArgumentError, not InvalidArgumentError. Keywords that no single operator accepts together (case_sensitive with tolerance on "==") are never "does not apply" for a value that resolves to an operator; they raise InvalidArgumentError. Every concrete class derives from PredicateError and from ValueError (ArgumentTypeError from TypeError), so existing handlers keep working; the bases PredicateError and NotApplicableError derive only from Exception.


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 which types it supports docs/symbols.md
See practical, real-world usage docs/patterns.md
Understand the architecture and design decisions docs/design.md
Navigate and understand the source docs/source-guide.md
Extend the library with operators, groups and symbols docs/extending.md

Metadata

Release files for vcti-predicate 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vcti-predicate 2.2.0
File Size Uploaded Provenance Actions
vcti_predicate-2.2.0.tar.gz 57.5 kB With provenance Details for vcti_predicate-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vcti-predicate 2.2.0
File Interpreter ABI Platform Actions
vcti_predicate-2.2.0-py3-none-any.whl Python 3 none any Details for vcti_predicate-2.2.0-py3-none-any.whl

Total release size: 87.9 kB

Release files / vcti_predicate-2.2.0.tar.gz

Download URL vcti_predicate-2.2.0.tar.gz
Size 57.5 kB
Tags Source
SHA-256 checksum
How to use checksums
45bdc1f65ed4f750f56d1d414a14761c8c92fa8849ea8ebcc12cfdd3633f278f
BLAKE2b-256 checksum
How to use checksums
5ca506dc769813c6a09c8518011398b953821182260e18a958db746e71124744
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 23, 2026.

Transparency log

Release files / vcti_predicate-2.2.0-py3-none-any.whl

Download URL vcti_predicate-2.2.0-py3-none-any.whl
Size 30.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
041e02d21919be04adabb62425fa54d58b66590e4c868f2c2bb06cc50d904417
BLAKE2b-256 checksum
How to use checksums
cf1ed71af544d4b9f3090ac96774209c7479a270916ccddf85c02b0ecb036290
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 23, 2026.

Transparency log

Security for vcti-predicate 2.2.0

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.

Select from 2 files

Attestation for vcti_predicate-2.2.0.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 23, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page