pavise.validators

Validators for DataFrame column validation with Annotated types.

Validators are simple data classes that define validation rules. The actual validation logic is implemented in backend-specific modules: - _pandas.validator_impl for pandas - _polars.validator_impl for polars

class pavise.validators.Range(min, max)[source]

Bases: object

Validate that numeric values are within a specified range.

Example

age: Annotated[int, Range(0, 150)]

Parameters:
min: float
max: float
class pavise.validators.Unique[source]

Bases: object

Validate that column values are unique (no duplicates).

Example

user_id: Annotated[int, Unique()]

class pavise.validators.In(allowed_values)[source]

Bases: object

Validate that column values are within a set of allowed values.

Example

status: Annotated[str, In([“pending”, “approved”, “rejected”])]

Parameters:

allowed_values (list)

allowed_values: list
class pavise.validators.Regex(pattern)[source]

Bases: object

Validate that string values match a regular expression pattern.

Example

email: Annotated[str, Regex(r’^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+.[a-zA-Z]{2,}$’)]

Parameters:

pattern (str)

pattern: str
class pavise.validators.MinLen(min_length)[source]

Bases: object

Validate that string values have a minimum length.

Example

username: Annotated[str, MinLen(3)]

Parameters:

min_length (int)

min_length: int
class pavise.validators.MaxLen(max_length)[source]

Bases: object

Validate that string values have a maximum length.

Example

username: Annotated[str, MaxLen(20)]

Parameters:

max_length (int)

max_length: int
class pavise.validators.Custom(func, message)[source]

Bases: object

Validate using a custom validation function.

The function should accept a single value and return True if valid, False otherwise.

Example

def is_positive(value) -> bool:

return value > 0

age: Annotated[int, Custom(is_positive, “must be positive”)]

Parameters:
func: Callable[[Any], bool]
message: str