( defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, options?: DecodingDefaultOptions )
| 6188 | * @since 3.10.0 |
| 6189 | */ |
| 6190 | export function withDecodingDefault<S extends Constraint, R = never>( |
| 6191 | defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, |
| 6192 | options?: DecodingDefaultOptions |
| 6193 | ): (self: S) => withDecodingDefault<S, R> { |
| 6194 | const encode = options?.encodingStrategy === "omit" ? SchemaGetter.omit() : SchemaGetter.passthrough() |
| 6195 | return (self: S): withDecodingDefault<S, R> => { |
| 6196 | return optional(toEncoded(self)).pipe(decodeTo(self, { |
| 6197 | decode: SchemaGetter.withDefault(toIssueEffect(defaultValue)), |
| 6198 | encode |
| 6199 | })) |
| 6200 | } |
| 6201 | } |
| 6202 | /** |
| 6203 | * Type-level representation returned by {@link withDecodingDefaultType}. |
| 6204 | * |
no test coverage detected