fastcfg.validation package

Submodules

fastcfg.validation.policies module

class fastcfg.validation.policies.LengthValidator(length: int, validate_immediately: bool = True)[source]

Bases: IConfigValidator

error_message() str[source]

Return the error message if validation fails.

validate(value: Any) bool[source]

Validate the given value.

class fastcfg.validation.policies.PydanticValidator(model: BaseModel, validate_immediately: bool = True, transform: bool = False)[source]

Bases: IConfigValidator

error_message() str[source]

Return the error message if validation fails.

validate(value: Any) bool[source]

Validate the given value.

class fastcfg.validation.policies.RangeValidator(min_value: int, max_value: int, validate_immediately: bool = True)[source]

Bases: IConfigValidator

error_message() str[source]

Return the error message if validation fails.

validate(value: Any) bool[source]

Validate the given value.

class fastcfg.validation.policies.RegexValidator(pattern: str, validate_immediately: bool = True)[source]

Bases: IConfigValidator

error_message() str[source]

Return the error message if validation fails.

validate(value: Any) bool[source]

Validate the given value.

class fastcfg.validation.policies.TypeValidator(expected_type: type, validate_immediately: bool = True)[source]

Bases: IConfigValidator

error_message() str[source]

Return the error message if validation fails.

validate(value: Any) bool[source]

Validate the given value.

class fastcfg.validation.policies.URLValidator(validate_immediately: bool = True)[source]

Bases: RegexValidator

error_message() str[source]

Return the error message if validation fails.

fastcfg.validation.validatable module

class fastcfg.validation.validatable.ValidatableMixin[source]

Bases: ABC

add_validator(validator: IConfigValidator) ValidatableMixin[source]
get_validators()[source]

Get the validators for the current validatable item.

validate(force_live: bool = False)[source]

Validate the current configuration item and its children.

This method performs validation on the current configuration item and its children. If the item is an instance of LiveConfigItem, it uses an MD5 hash to track the state of the item’s value. Validation is only performed if the state has changed or if the force_live parameter is set to True.

Parameters: force_live (bool): If True, forces validation for LiveConfigItem instances

regardless of whether the state has changed. This is useful when a new validator is added and immediate validation is required.

Raises: ConfigItemValidationError: If any of the validators fail.

abstract property value: Any
fastcfg.validation.validatable.md5_hash_state(input_obj: Any) str[source]

Hash LiveConfig object’s state

Module contents

class fastcfg.validation.IConfigValidator(validate_immediately: bool = True)[source]

Bases: ABC

abstractmethod error_message() str[source]

Return the error message if validation fails.

abstractmethod validate(value: Any) bool[source]

Validate the given value.