Skip to main content

VCollab Predicate - condition evaluation engine with extensible operators and modifiers

Project description

Predicate Evaluator

Purpose

VCollab applications frequently need to evaluate conditions — "is this value greater than X?", "does this string contain Y?", "does this list include Z?" These checks appear in filtering, validation, workflow conditionals, and routing logic.

The vcti-predicate package provides two entry points — check() and evaluate() — that resolve the right comparison logic based on the operand types, apply type-appropriate normalization, and support extensible operators with group-level and operator-specific options.

This package has zero external dependencies.


Installation

pip install vcti-predicate

In requirements.txt

vcti-predicate>=1.0.7

In pyproject.toml dependencies

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

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 tuple of bounds)
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 tuple)

Modifier Suffixes

Append cs or ic to string symbols for case control: ^=cs, $=ic, ?=cs, @=ic, ~=cs

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 Groups Default Effect
case_sensitive string, collection, regex False Case-sensitive comparison
tolerance float 0.0 Maximum difference for equality
inclusive range True Include bounds in range check

Documentation

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

vcti_predicate-1.0.7.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

vcti_predicate-1.0.7-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file vcti_predicate-1.0.7.tar.gz.

File metadata

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

File hashes

Hashes for vcti_predicate-1.0.7.tar.gz
Algorithm Hash digest
SHA256 389d4e5c3c72fce2208845801bf980f49e72860dbe51c11e762ae9c8be72739a
MD5 c30d0e9b53b893525aa003d52ac292c8
BLAKE2b-256 90ac0eb3ca4e567069b81d3974784d186b515f95c07941f5b1f3ce1e145a6e39

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_predicate-1.0.7.tar.gz:

Publisher: publish.yml on vcollab/vcti-python-predicate

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

File details

Details for the file vcti_predicate-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: vcti_predicate-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vcti_predicate-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 97e72b4e03ea40819e7f244b713f4af87d6d38313ad14222c1453c0f8427f7ef
MD5 a8081bb1aaa248cb091d0379ffbfa7c7
BLAKE2b-256 a1dcc85ebda3749123e16d61d07188af7059980f8fd8fb040a077131b0df8a34

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_predicate-1.0.7-py3-none-any.whl:

Publisher: publish.yml on vcollab/vcti-python-predicate

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