Skip to content

Commit

Permalink
Migrate from @root_validator to @model_validator for `AccessRequi…
Browse files Browse the repository at this point in the history
…rements`
  • Loading branch information
candleindark committed Dec 4, 2023
1 parent c5b51bb commit 7fcb9be
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions dandischema/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
ValidationInfo,
field_validator,
model_validator,
root_validator,
)

from .consts import DANDI_SCHEMA_VERSION
Expand Down Expand Up @@ -910,15 +909,15 @@ class AccessRequirements(DandiBaseModel):

_ldmeta = {"rdfs:subClassOf": ["schema:Thing", "prov:Entity"], "nskey": "dandi"}

@root_validator
def open_or_embargoed(cls, values: Dict[str, Any]) -> Dict[str, Any]:
status, embargoed = values.get("status"), values.get("embargoedUntil")
@model_validator(mode="after")
def open_or_embargoed(self) -> "AccessRequirements":
status, embargoed = self.status, self.embargoedUntil
if status == AccessType.EmbargoedAccess and embargoed is None:
raise ValueError(
"An embargo end date is required for NIH awards to be in "
"compliance with NIH resource sharing policy."
)
return values
return self


class AssetsSummary(DandiBaseModel):
Expand Down

0 comments on commit 7fcb9be

Please sign in to comment.