@@ -40,9 +40,20 @@ class BaseClaimsRegistry:
4040
4141 def __init__ (self , ** kwargs : ClaimsOption ):
4242 self .options = kwargs
43- self .essential_keys = {key for key in kwargs if kwargs [key ].get ("essential" )}
43+
44+ @property
45+ def essential_keys (self ) -> set [str ]:
46+ """Returns the essential claim names."""
47+ return {key for key in self .options if self .options [key ].get ("essential" )}
4448
4549 def check_value (self , claim_name : str , value : Any ) -> None :
50+ """
51+ Validates a given claim value based on predefined options.
52+
53+ :param claim_name: The name of the claim to validate.
54+ :param value: The value of the claim to be validated.
55+ :raises InvalidClaimError: If the value does not meet the claim's validation requirements.
56+ """
4657 option = self .options .get (claim_name )
4758 if not option :
4859 return
@@ -69,6 +80,13 @@ def check_value(self, claim_name: str, value: Any) -> None:
6980 raise InvalidClaimError (claim_name )
7081
7182 def validate (self , claims : dict [str , Any ]) -> None :
83+ """
84+ Validates the provided claims against specified requirements and checks.
85+
86+ :param claims: A dictionary containing claims to validate.
87+ :raises InvalidClaimError: Raised if any claim fails validation.
88+ :raises MissingClaimError: Raised if one or more essential keys are missing.
89+ """
7290 missed_keys = {key for key in self .essential_keys if claims .get (key ) is None }
7391 if missed_keys :
7492 raise MissingClaimError ("," .join (sorted (missed_keys )))
@@ -99,6 +117,7 @@ def __init__(self, now: int | Callable[[], int] | None = None, leeway: int = 0,
99117
100118 @property
101119 def now (self ) -> int :
120+ """Returns the current timestamp."""
102121 if callable (self ._now ):
103122 return self ._now ()
104123 return self ._now
0 commit comments