xtl.common.validators module#

This modules defines custom validators to be used with Pydantic models.

xtl.common.validators.CastAsNoneIfEmpty()[source]#

Pydantic validator to cast a value to None if it is empty.

Return type:

BeforeValidator

xtl.common.validators.CastAsPathOrNone()[source]#

Pydantic validator to cast a value to a Path or return None if the value is empty.

Return type:

BeforeValidator

xtl.common.validators.CastAsValidator(type_)[source]#

Pydantic validator to cast a value to the specified type.

Parameters:

type_ (type | Callable)

Return type:

BeforeValidator

xtl.common.validators.ChoicesValidator(choices)[source]#

Pydantic validator to check if a value is in the provided choices.

Parameters:

choices (str | tuple[Any, ...])

Return type:

AfterValidator

xtl.common.validators.LengthValidator(length)[source]#

Pydantic validator to check if the length of a value is equal to the provided length.

Parameters:

length (int)

Return type:

AfterValidator

xtl.common.validators.PathExistsValidator()[source]#

Pydantic validator to check if a path exists.

Return type:

AfterValidator

xtl.common.validators.PathIsAbsoluteValidator()[source]#

Pydantic validator to check if a path is absolute.

Return type:

AfterValidator

xtl.common.validators.PathIsDirValidator()[source]#

Pydantic validator to check if a path is a directory.

Return type:

AfterValidator

xtl.common.validators.PathIsFileValidator()[source]#

Pydantic validator to check if a path is a file.

Return type:

AfterValidator