with_decoding_default_key(default): apply with .pipe.
Functions#
__init__#
__init__(default, strategy) -> None| Parameter | Type | Description |
|---|---|---|
default | Effect[A, SchemaError, R_co] | |
strategy | EncodingStrategy |
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]| Parameter | Type | Description |
|---|---|---|
schema | Codec[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))