Bases: str
ChecksumAddress with validation.
Functions
__new__
Source code in derive_client/data_types/models.py
| def __new__(cls, v: str) -> ChecksumAddress:
if not is_address(v):
raise ValueError(f"Invalid Ethereum address: {v}")
return cast(ChecksumAddress, to_checksum_address(v))
|
__get_pydantic_core_schema__
classmethod
__get_pydantic_core_schema__(
_source, _handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in derive_client/data_types/models.py
| @classmethod
def __get_pydantic_core_schema__(cls, _source, _handler: GetCoreSchemaHandler) -> core_schema.CoreSchema:
return core_schema.no_info_before_validator_function(cls._validate, core_schema.any_schema())
|
__get_pydantic_json_schema__
classmethod
__get_pydantic_json_schema__(
_schema, _handler: GetJsonSchemaHandler
) -> dict
Source code in derive_client/data_types/models.py
| @classmethod
def __get_pydantic_json_schema__(cls, _schema, _handler: GetJsonSchemaHandler) -> dict:
return {"type": "string", "format": "ethereum-address"}
|
_validate
classmethod
Source code in derive_client/data_types/models.py
125
126
127
128
129
130
131 | @classmethod
def _validate(cls, v) -> ChecksumAddress:
if isinstance(v, cls):
return v
if not isinstance(v, str):
raise TypeError(f"Expected str, got {type(v)}")
return cls(v)
|