mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
fix FilePath and DirectoryPath (#226)
This commit is contained in:
@@ -329,6 +329,7 @@ class FilePath(Path):
|
||||
yield path_exists_validator
|
||||
yield cls.validate
|
||||
|
||||
@classmethod
|
||||
def validate(cls, value: Path) -> Path:
|
||||
if not value.is_file():
|
||||
raise errors.PathNotAFileError(path=value)
|
||||
@@ -343,6 +344,7 @@ class DirectoryPath(Path):
|
||||
yield path_exists_validator
|
||||
yield cls.validate
|
||||
|
||||
@classmethod
|
||||
def validate(cls, value: Path) -> Path:
|
||||
if not value.is_dir():
|
||||
raise errors.PathNotADirectoryError(path=value)
|
||||
|
||||
Reference in New Issue
Block a user