Skip to content

Commit

Permalink
Fix model_validator example usage code (#8141)
Browse files Browse the repository at this point in the history
  • Loading branch information
ventaquil committed Nov 15, 2023
1 parent 08f195b commit 91bc828
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pydantic/functional_validators.py
Expand Up @@ -504,14 +504,14 @@ def model_validator(
from pydantic import BaseModel, ValidationError, model_validator
class Square(BaseModel):
width: float
height: float
@model_validator(mode='after')
def verify_square(self) -> 'Rectangle':
if self.width != self.height:
raise ValueError('width and height do not match')
return self
width: float
height: float
@model_validator(mode='after')
def verify_square(self) -> 'Rectangle':
if self.width != self.height:
raise ValueError('width and height do not match')
return self
s = Square(width=1, height=1)
print(repr(s))
Expand Down

0 comments on commit 91bc828

Please sign in to comment.