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.1.0

In pyproject.toml dependencies

dependencies = [
    "vcti-predicate>=2.1.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 UnsupportedOperandError when, and only when, the symbol has no operator for the value's type (for example None with "^="): the condition does not apply to that value. A condition that is wrong for the operator it resolved to raises UnknownSymbolError, ArityError, InvalidArgumentError or ArgumentTypeError. What an operator accepts can depend on the value's type (tolerance applies to a float, not an int), so these are not all independent of the data, but none of them means "does not apply". All derive from PredicateError and from ValueError (ArgumentTypeError from TypeError), so existing handlers keep working.


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.1.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.1.0
File Size Uploaded Provenance Actions
vcti_predicate-2.1.0.tar.gz 51.8 kB With provenance Details for vcti_predicate-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 79.7 kB

Release files / vcti_predicate-2.1.0.tar.gz

Download URL vcti_predicate-2.1.0.tar.gz
Size 51.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b534d36eb31f242f969bc41e9fdbf3b908424eb856f1ea197911c2553f0b2eea
BLAKE2b-256 checksum
How to use checksums
abb4fb3f7ed64f3d12a00c51f764dbd05714b972b4e3927638b7884f87373ccf
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 22, 2026.

Transparency log

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

Download URL vcti_predicate-2.1.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23382bdb38668aa7a8fb6762b0144a14c9953ab43ed178933752c1f7f4e33b1b
BLAKE2b-256 checksum
How to use checksums
2bfeee105690d4d1572f19e91fa0f32a3edba93fc1ede4aa24ede7854a16238e
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 22, 2026.

Transparency log

Security for vcti-predicate 2.1.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.1.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 22, 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