argclz.validator.TupleValidatorBuilder#

class argclz.validator.TupleValidatorBuilder[source]#

Bases: AbstractTypeValidatorBuilder[tuple]

a tuple validator

__init__(element_type)[source]#
Parameters:

element_type (tuple[Any, ...])

Methods Summary

__init__(element_type)

freeze()

(internal use) return a copy of itself.

on_item(item, validator)

Apply a validator to specific tuple positions

optional()

__call__(value)

Details

freeze()[source]#

(internal use) return a copy of itself.

Return type:

Self

on_item(item, validator)[source]#

Apply a validator to specific tuple positions

Parameters:
  • item (int | list[int] | None) – A single index, a list of indices, or None for all indices

  • validator (Callable[[Any], bool]) – The validation callable to apply

Return type:

Self

__call__(value)[source]#
Parameters:

value (Any) – type-casted value.

Returns:

True if value pass the validation.

Raises:

ValueError – when value does not pass the validation.

Return type:

bool

optional()#
Return type:

Self