Skip to content

Dependent argument validator

DependsOn(*args, args_strategy=MustBeLessThan, kw_strategy=MustBeProvided, args_err_msg=None, kw_err_msg=None, extra_msg_args=None, **kwargs)

Bases: Validator

Class to indicate that a function argument depends on another argument.

When an argument is marked as depending on another, it implies that the presence or value of one argument may influence the validation or necessity of the other.

PARAMETER DESCRIPTION
args

The names of the arguments that the current argument depends on.

TYPE: str DEFAULT: ()

args_strategy

The validation strategy to apply based on the values of the dependent arguments.

TYPE: Type[Validator] DEFAULT: MustBeLessThan

kw_strategy

The validation strategy to apply when dependent arguments match specific values.

TYPE: Type[Validator] DEFAULT: MustBeProvided

kwargs

Key-value pairs where the key is the name of the dependent argument and the value is the specific value to match for applying the strategy.

TYPE: T DEFAULT: {}