MCPcopy
hub / github.com/pydantic/pydantic / validate_error

Method validate_error

tests/test_generics.py:577–583  ·  view source on GitHub ↗
(cls, v: Optional[error_type], info: ValidationInfo)

Source from the content-addressed store, hash-verified

575 @field_validator('error')
576 @classmethod
577 def validate_error(cls, v: Optional[error_type], info: ValidationInfo) -> Optional[error_type]:
578 values = info.data
579 if values.get('data', None) is None and v is None:
580 raise ValueError('Must provide data or error')
581 if values.get('data', None) is not None and v is not None:
582 raise ValueError('Must not provide both data and error')
583 return v
584
585 @field_validator('positive_number')
586 @classmethod

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected