Skip to content

Commit

Permalink
update docstrings for validators
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanhphan1147 committed Nov 9, 2023
1 parent 815c509 commit ad738dc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ def __init__(self, msg: str = ""):
self.msg = msg

class Validator(BaseModel):
"""Pydantic validator for various attributes
Attrs:
http_url_validator: assign a value to this attribute to validate it against pydantic's HttpUrl type
"""
http_url_validator: HttpUrl

class JenkinsConfig(BaseModel):
Expand All @@ -53,7 +58,16 @@ class JenkinsConfig(BaseModel):

@validator("server_url")
def valid_http_url(cls, server_url: str):
"""Pydantic validator for sever_url attribute
Args:
server_url: the server_url attribute to validate
Returns:
the validated server_url attribute
"""
_ = Validator(http_url_validator = server_url)
return server_url

@classmethod
def from_charm_config(cls, config: ops.ConfigData) -> typing.Optional["JenkinsConfig"]:
Expand Down

0 comments on commit ad738dc

Please sign in to comment.