GitHub

WithDecodingDefaultKey

API reference for WithDecodingDefaultKey.

with_decoding_default_key(default): apply with .pipe.

Functions

__init__

__init__(default, strategy) -> None
ParameterTypeDescription
defaultEffect[A, SchemaError, R_co]
strategyEncodingStrategy
def __init__(self, default: Effect[A, SchemaError, R_co], strategy: EncodingStrategy) -> None:
    self._default = default
    self._strategy: EncodingStrategy = strategy

__call__

__call__[T, RD = Never, RE = Never](schema) -> DecodeToSchema[T, A, RD | R_co, RE]
ParameterTypeDescription
schemaCodec[T, A, RD, RE]

Returns DecodeToSchema[T, A, RD | R_co, RE]

def __call__[T, RD = Never, RE = Never](
    self, schema: Codec[T, A, RD, RE], /
) -> DecodeToSchema[T, A, RD | R_co, RE]:
    default = with_default(_issue_outcome(self._default))
    encode: Getter[Any, Any] = omit()
    if self._strategy == "passthrough":
        encode = passthrough()
    transformation: Transformation[Any, Any, Any, Any] = Transformation(default, encode)
    return optional_key(to_encoded(schema)).pipe(decode_to(schema, transformation))