Skip to content

Commit

Permalink
Make field validators classmethods
Browse files Browse the repository at this point in the history
  • Loading branch information
sneakers-the-rat authored Jul 9, 2024
1 parent 470f71a commit 52fd580
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/curies/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class Record(BaseModel): # type:ignore
)

@field_validator("prefix_synonyms") # type:ignore
@classmethod
def prefix_not_in_synonyms(cls, v: str, values: Mapping[str, Any]) -> str: # noqa:N805
"""Check that the canonical prefix does not apper in the prefix synonym list."""
prefix = get_field_validator_values(values, "prefix")
Expand All @@ -283,6 +284,7 @@ def prefix_not_in_synonyms(cls, v: str, values: Mapping[str, Any]) -> str: # no
return v

@field_validator("uri_prefix_synonyms") # type:ignore
@classmethod
def uri_prefix_not_in_synonyms(cls, v: str, values: Mapping[str, Any]) -> str: # noqa:N805
"""Check that the canonical URI prefix does not apper in the URI prefix synonym list."""
uri_prefix = get_field_validator_values(values, "uri_prefix")
Expand Down

0 comments on commit 52fd580

Please sign in to comment.