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:
- xtl.common.validators.CastAsPathOrNone()[source]#
Pydantic validator to cast a value to a
Path
or returnNone
if the value is empty.- Return type:
- xtl.common.validators.CastAsValidator(type_)[source]#
Pydantic validator to cast a value to the specified type.
- Parameters:
type_ (type | Callable)
- Return type:
- 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:
- 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:
- xtl.common.validators.PathExistsValidator()[source]#
Pydantic validator to check if a path exists.
- Return type:
- xtl.common.validators.PathIsAbsoluteValidator()[source]#
Pydantic validator to check if a path is absolute.
- Return type:
- xtl.common.validators.PathIsDirValidator()[source]#
Pydantic validator to check if a path is a directory.
- Return type: