( defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, options?: DecodingDefaultOptions )
| 5991 | * @since 3.10.0 |
| 5992 | */ |
| 5993 | export function withDecodingDefault<S extends Constraint, R = never>( |
| 5994 | defaultValue: Effect.Effect<S["Encoded"], SchemaError, R>, |
| 5995 | options?: DecodingDefaultOptions |
| 5996 | ) { |
| 5997 | const encode = options?.encodingStrategy === "omit" ? SchemaGetter.omit() : SchemaGetter.passthrough() |
| 5998 | return (self: S): withDecodingDefault<S, R> => { |
| 5999 | return optional(toEncoded(self)).pipe(decodeTo(self, { |
| 6000 | decode: SchemaGetter.withDefault(toIssueEffect(defaultValue)), |
| 6001 | encode |
| 6002 | })) |
| 6003 | } |
| 6004 | } |
| 6005 | |
| 6006 | /** |
| 6007 | * Type-level representation returned by {@link withDecodingDefaultType}. |
no test coverage detected