Skip to main content

EncodedStr

A str type that is encoded and decoded using the specified encoder.

Attributes

AttributeTypeDescription
encodertype[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)]The class implementing EncoderProtocol used to transform data between its encoded and decoded string representations.

Constructor

Signature

def EncodedStr(
encoder: type[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)]
)

Parameters

NameTypeDescription
encodertype[[EncoderProtocol](encoderprotocol.md?sid=pydantic_types_encoderprotocol)]The encoder class used for encoding and decoding string data.

Methods


decode_str()

@classmethod
def decode_str(
data: str,
_: core_schema.ValidationInfo
) - > str

Decode the data using the specified encoder.

Parameters

NameTypeDescription
datastrThe data to decode.
_core_schema.ValidationInfoPydantic validation context, currently unused by this implementation.

Returns

TypeDescription
strThe decoded data.

encode_str()

@classmethod
def encode_str(
value: str
) - > str

Encode the data using the specified encoder.

Parameters

NameTypeDescription
valuestrThe data to encode.

Returns

TypeDescription
strThe encoded data.