Open Ravencentric opened 5 months ago
@Ravencentric,
Thanks for the feature request. I'm sure many people would appreciate extended support for these types. The right place for these, though, is in pydantic-extra-types
. I'll transfer this issue over there 👍.
Makes sense, thank you!
Initial Checks
Description
Working with Paths is fairly common and I usually end up writing my own field validator over and over again because the type I want is missing. I would like to see the Path types in pydantic extended with some more potentially useful types:
ExistingPath
-Union[FilePath, DirectoryPath]
ResolvedFilePath
- A file that get's resolved (pathlib.Path.expanduser().resolve()
) by pydantic before returningResolvedDirectoryPath
- A directory that get's resolved (pathlib.Path.expanduser().resolve()
) by pydantic before returningResolvedPath
-Union[ResolvedFilePath, ResolvedDirectoryPath]
My current solution is to just write a field validator:
Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM mode