( defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, options?: DecodingDefaultOptions )
| 5884 | * @since 4.0.0 |
| 5885 | */ |
| 5886 | export function withDecodingDefaultKey<S extends Constraint, R = never>( |
| 5887 | defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, |
| 5888 | options?: DecodingDefaultOptions |
| 5889 | ) { |
| 5890 | const encode = options?.encodingStrategy === "omit" ? SchemaGetter.omit() : SchemaGetter.passthrough() |
| 5891 | return (self: S): withDecodingDefaultKey<S, R> => { |
| 5892 | return optionalKey(toEncoded(self)).pipe(decodeTo(self, { |
| 5893 | decode: SchemaGetter.withDefault(toIssueEffect(defaultValue)), |
| 5894 | encode |
| 5895 | })) |
| 5896 | } |
| 5897 | } |
| 5898 | |
| 5899 | /** |
| 5900 | * Type-level representation returned by {@link withDecodingDefaultTypeKey}. |
no test coverage detected