5.1. Errors

class pathvalidate.error.ErrorReason(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Validation error reasons.

FOUND_ABS_PATH = ('PV1200', 'FOUND_ABS_PATH', 'found an absolute path where must be a relative path')
INVALID_AFTER_SANITIZE = ('PV2000', 'INVALID_AFTER_SANITIZE', 'found invalid value after sanitizing')
INVALID_CHARACTER = ('PV1100', 'INVALID_CHARACTER', 'invalid characters found')
INVALID_LENGTH = ('PV1101', 'INVALID_LENGTH', 'found an invalid string length')
MALFORMED_ABS_PATH = ('PV1201', 'MALFORMED_ABS_PATH', 'found a malformed absolute path')
NULL_NAME = ('PV1001', 'NULL_NAME', 'the value must not be an empty string')
RESERVED_NAME = ('PV1002', 'RESERVED_NAME', 'found a reserved name by a platform')
property code: str

Error code.

Type:

str

property description: str

Error reason description.

Type:

str

property name: str

Error reason name.

Type:

str

Liar od Errors

Code

Name

Description

PV1001

NULL_NAME

the value must not be an empty

PV1002

RESERVED_NAME

found a reserved name by a platform

PV1100

INVALID_CHARACTER

invalid characters found

PV1101

INVALID_LENGTH

found an invalid string length

PV1200

FOUND_ABS_PATH

found an absolute path where must be a relative path

PV1201

MALFORMED_ABS_PATH

found a malformed absolute path

PV2000

INVALID_AFTER_SANITIZE

found invalid value after sanitizing

exception pathvalidate.error.ValidationError(*args, **kwargs)[source]

Bases: ValueError

Exception class of validation errors.

as_slog() Dict[str, str][source]

Return a dictionary representation of the error.

Returns:

A dictionary representation of the error.

Return type:

Dict[str, str]

property byte_count: int | None

Byte count of the path.

Type:

Optional[int]

property description: str | None

Error description.

Type:

Optional[str]

property fs_encoding: str | None

File system encoding.

Type:

Optional[str]

property platform: Platform | None

Platform information.

Type:

Platform

property reason: ErrorReason

The cause of the error.

Type:

ErrorReason

property reserved_name: str

Reserved name.

Type:

str

property reusable_name: bool | None

Whether the name is reusable or not.

Type:

Optional[bool]