style: Prefix id_is_positive_integer with validate_¶
Description¶
Abstract¶
In isshub.domain.utils.entity.BaseModelWithId, rename id_is_positive_integer to validate_id_is_positive_integer.
Motivation¶
Having a meaningful name is the first thing to help knowing what a function does. Here, without the validate_ prefix, we couldn’t guess at first sight, in the documentation (where the decorators are not shown) that it was a validator function.
Rationale¶
Nothing to do more that renaming the method: the @field_validator track its methods and we don’t have to call them directly.
Info¶
- Hash
a307cce6ee202cb7562f2db1afaff499a31508a2
- Date
2020-09-25 23:37:35 +0200
- Parents
docs(source): Add emphasis to the first line of docstrings [cc73cb6a] — 2020-09-25 23:37:34 +0200
- Children
docs(git): Show source of renamed files [56390227] — 2020-09-25 23:37:36 +0200
- Branches
- Tags
(No tags)
Changes¶
isshub/domain/utils/entity.py¶
- Type
Modified
- Stats
+1 -1
@@ -154,7 +154,7 @@ class BaseModelWithId(BaseModel):
id: int = required_field(int)
@field_validator(id)
- def id_is_positive_integer( # noqa # pylint: disable=unused-argument
+ def validate_id_is_positive_integer( # noqa # pylint: disable=unused-argument
self, field, value
):
"""Validate that the ``id`` field is a positive integer.