File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ constraints:
251251# ## Reference
252252
253253Bibliographic pointer.
254- Requires a `title` and `authors ` and optionally includes a `link` to the material .
254+ Requires either a `title` or a `link ` and optionally a list of `authors` .
255255
256256` ` ` yaml
257257references:
Original file line number Diff line number Diff line change @@ -73,16 +73,18 @@ def __hash__(self):
7373
7474
7575class Reference (BaseModel ):
76- title : str
77- authors : list [str ]
76+ title : str | None = None
77+ authors : list [str ] | None = None
7878 link : Link | None = None
7979
80+ @model_validator (mode = "after" )
81+ def _validate (self ) -> Self :
82+ if self .title is None and self .link is None :
83+ raise ValueError ("References must have either a title or a link." )
84+ return self
85+
8086 def __hash__ (self ):
81- return (
82- hash (self .title )
83- + sum ([hash (author ) for author in self .authors ])
84- + hash (self .link )
85- )
87+ return hash (self .title ) + hash (self .link )
8688
8789
8890class Usage (BaseModel ):
You can’t perform that action at this time.
0 commit comments