MCPcopy
hub / github.com/pydantic/pydantic / validate_sum

Method validate_sum

tests/test_generics.py:105–109  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

103
104 @model_validator(mode='after')
105 def validate_sum(self) -> 'Response[T]':
106 data = self.data
107 if sum(data.values()) > 5:
108 raise ValueError('sum too large')
109 return self
110
111 assert Response[dict[int, int]](data={1: '4'}).model_dump() == {'data': {1: 4}}
112 with pytest.raises(ValidationError) as exc_info:

Callers

nothing calls this directly

Calls 1

valuesMethod · 0.80

Tested by

no test coverage detected