Skip to content

Collection validators

MustBeMemberOf(value_set, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the value is a member of the specified set.

PARAMETER DESCRIPTION
value_set

The set of values to validate against. value_set must support the in operator.

TYPE: Container

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustBeEmpty(*, err_msg=None, extra_msg_args=None)

Bases: Validator

PARAMETER DESCRIPTION
err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustBeNonEmpty(*, err_msg=None, extra_msg_args=None)

Bases: Validator

PARAMETER DESCRIPTION
err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveLengthEqual(value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length equal to the specified value.

PARAMETER DESCRIPTION
value

The length of the iterable.

TYPE: int

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveLengthGreaterThan(value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length greater than the specified value.

PARAMETER DESCRIPTION
value

The length of the iterable.

TYPE: int

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveLengthGreaterThanOrEqual(value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length greater than or equal to the specified value.

PARAMETER DESCRIPTION
value

The length of the iterable.

TYPE: int

err_msg

Error message

TYPE: Optional[str] DEFAULT: None

MustHaveLengthLessThan(value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length less than the specified value.

PARAMETER DESCRIPTION
value

The length of the iterable.

TYPE: int

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveLengthLessThanOrEqual(value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length less than or equal to the specified value.

PARAMETER DESCRIPTION
value

The length of the iterable.

TYPE: int

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveLengthBetween(*, min_value, max_value, min_inclusive=True, max_inclusive=True, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that the iterable has length between the specified min_value and max_value.

PARAMETER DESCRIPTION
min_value

The minimum value (inclusive or exclusive based on min_inclusive).

TYPE: int

max_value

The maximum value (inclusive or exclusive based on max_inclusive).

TYPE: int

min_inclusive

If True, min_value is inclusive.

TYPE: bool DEFAULT: True

max_inclusive

If True, max_value is inclusive.

TYPE: bool DEFAULT: True

err_msg

error message.

TYPE: Optional[str] DEFAULT: None

MustHaveValuesGreaterThan(min_value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that all values in the iterable are greater than the specified min_value.

PARAMETER DESCRIPTION
min_value

The minimum value the values in the iterable should be greater than.

TYPE: Number

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveValuesGreaterThanOrEqual(min_value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that all values in the iterable are greater than or equal to the specified min_value.

PARAMETER DESCRIPTION
min_value

The minimum value the values in the iterable should be greater than or equal to.

TYPE: Number

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveValuesLessThan(max_value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that all values in the iterable are less than the specified max_value.

PARAMETER DESCRIPTION
max_value

The maximum value the values in the iterable should be less than.

TYPE: Number

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveValuesLessThanOrEqual(max_value, *, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that all values in the iterable are less than or equal to the specified max_value.

PARAMETER DESCRIPTION
max_value

The maximum value the values in the iterable should be less than or equal to.

TYPE: Number

err_msg

Error message.

TYPE: Optional[str] DEFAULT: None

MustHaveValuesBetween(*, min_value, max_value, min_inclusive=True, max_inclusive=True, err_msg=None, extra_msg_args=None)

Bases: Validator

Validates that all values in the iterable are between the specified min_value and max_value.

PARAMETER DESCRIPTION
min_value

The minimum value (inclusive or exclusive based on min_inclusive).

TYPE: Number

max_value

The maximum value (inclusive or exclusive based on max_inclusive).

TYPE: Number

min_inclusive

If True, min_value is inclusive.

TYPE: bool DEFAULT: True

max_inclusive

If True, max_value is inclusive.

TYPE: bool DEFAULT: True

err_msg

error message.

TYPE: Optional[str] DEFAULT: None