Validate doc type data during build
This commit is contained in:
parent
373dfe4c3b
commit
f13e1e2ee2
7 changed files with 195 additions and 20 deletions
|
|
@ -48,6 +48,7 @@ from typing import Annotated, Any
|
|||
from pydantic import (
|
||||
AnyUrl,
|
||||
BaseModel,
|
||||
ConfigDict,
|
||||
EmailStr,
|
||||
Field,
|
||||
PositiveInt,
|
||||
|
|
@ -209,6 +210,26 @@ class ITSystem(BaseModel):
|
|||
quality_related: bool
|
||||
|
||||
|
||||
class InformationType(BaseModel):
|
||||
"""A type/kind/class of Information, Document, or Record."""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
name: str
|
||||
abbrev: str
|
||||
examples: list[str] | None = None
|
||||
description: str = ""
|
||||
retention: str | None = ""
|
||||
record: bool = True
|
||||
use_cases: str = ""
|
||||
notes: str = ""
|
||||
parent: InformationType | None = None
|
||||
|
||||
|
||||
InformationTypes = TypeAdapter(list[InformationType])
|
||||
"""A list of document types."""
|
||||
|
||||
|
||||
class Document(BaseModel):
|
||||
"""
|
||||
Data dictionary entry for Documents and Records.
|
||||
|
|
@ -363,6 +384,9 @@ class Document(BaseModel):
|
|||
|
||||
Retention plans define how long the document or record is to be
|
||||
kept before it is destroyed.
|
||||
|
||||
.. note:: May want this to actually be a timedelta
|
||||
|
||||
"""
|
||||
|
||||
LIFETIME = "LIFETIME"
|
||||
|
|
@ -411,6 +435,10 @@ class Document(BaseModel):
|
|||
description="Filenames of files attached to this Document. Main file should be the first.",
|
||||
default=[],
|
||||
)
|
||||
file_notes: list[str] = Field(
|
||||
description="Short description of each file represented in filenames.",
|
||||
default=[],
|
||||
)
|
||||
checksums: list[str] = Field(
|
||||
description="SHA-256 checksum of each file for data integrity", default=[]
|
||||
)
|
||||
|
|
@ -420,9 +448,12 @@ class Document(BaseModel):
|
|||
easier periodic re-verification of large data libraries."""
|
||||
|
||||
physical_location: str | None = Field(
|
||||
description="Location of a media when not stored as an electronic file.",
|
||||
description="Location of a media (only valid when not stored as an electronic file).",
|
||||
default=None,
|
||||
)
|
||||
notes: str = Field(
|
||||
description="Additional information about the Document/Record", default=""
|
||||
)
|
||||
|
||||
@field_validator("type", mode="after")
|
||||
@classmethod
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue