Skip to content

Commit

Permalink
Make field validators classmethods (#112)
Browse files Browse the repository at this point in the history
Fixes #111

Co-authored-by: Charles Tapley Hoyt <[email protected]>
  • Loading branch information
sneakers-the-rat and cthoyt authored Jul 9, 2024
1 parent a6ab32e commit 161cf4e
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 161cf4e

Please sign in to comment.