Validators API¶
Cross-field validation DSL for creating expressions that work with both Polars and Pydantic.
Field References¶
col(name)
¶
FieldRef(name)
¶
Bases: _MathOpsMixin, _MembershipMixin
Reference to a field that can compile to Polars expressions and Python callables.
Source code in src/flycatcher/validators/core.py
Expression Classes¶
BinaryOp(left, op, right)
¶
Bases: _MathOpsMixin, _ExpressionMixin, _MembershipMixin
Binary operation that can compile to both Polars and Python.
Source code in src/flycatcher/validators/ops.py
UnaryOp(op, operand, arg=None)
¶
Bases: _MathOpsMixin, _ExpressionMixin, _MembershipMixin
Unary operation that can compile to both Polars and Python.
Source code in src/flycatcher/validators/ops.py
str
property
¶
Access string operations on this expression.
dt
property
¶
Access datetime operations on this expression.
to_polars()
¶
Compile to Polars expression.
Source code in src/flycatcher/validators/ops.py
to_python(values)
¶
Evaluate in Python context.
Source code in src/flycatcher/validators/ops.py
StringAccessor(expr)
¶
StringOp(op, operand, arg=None)
¶
Bases: _ExpressionMixin, _MembershipMixin
String operation that can compile to both Polars and Python.
Source code in src/flycatcher/validators/string.py
str
property
¶
Access string operations on this expression (for chaining).
dt
property
¶
Access datetime operations on this expression (for chaining).
to_polars()
¶
Compile to Polars expression.
Source code in src/flycatcher/validators/string.py
to_python(values)
¶
Evaluate in Python context.
Source code in src/flycatcher/validators/string.py
DateTimeAccessor(expr)
¶
Accessor for datetime operations on expressions.
Source code in src/flycatcher/validators/datetime.py
year()
¶
month()
¶
day()
¶
hour()
¶
minute()
¶
second()
¶
total_days(other)
¶
Calculate the difference in days between this value and another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
datetime, date, or FieldRef
|
The value to compare against. |
required |
Returns:
| Type | Description |
|---|---|
DateTimeOp
|
An expression evaluating to the number of days difference (float), positive if this value is later. |
Source code in src/flycatcher/validators/datetime.py
DateTimeOp(op, operand, arg=None)
¶
Bases: _ExpressionMixin, _MembershipMixin
Datetime operation that can compile to both Polars and Python.
This class represents datetime operations (like extracting year, month, or calculating differences) that work seamlessly in both Polars DataFrame validation and Pydantic row-level validation contexts.
Source code in src/flycatcher/validators/datetime.py
dt
property
¶
Access datetime operations on this expression (for chaining).
ValidatorResult(result)
¶
Wrapper for validator results supporting multiple formats.
Source code in src/flycatcher/validators/core.py
get_polars_validator()
¶
Extract Polars validator as (expression, message) tuple.
Source code in src/flycatcher/validators/core.py
get_pydantic_validator()
¶
Extract Pydantic validator callable, or None if not available.