(
from: Schema<FA, FI, FR>,
to: Schema<TA, TI, TR>,
options: {
readonly decode: (fa: FA) => option_.Option<TI>
readonly encode: (o: option_.Option<TI>) => FA
}
)
| 2273 | * @since 3.10.0 |
| 2274 | */ |
| 2275 | export const requiredToOptional = <FA, FI, FR, TA, TI, TR>( |
| 2276 | from: Schema<FA, FI, FR>, |
| 2277 | to: Schema<TA, TI, TR>, |
| 2278 | options: { |
| 2279 | readonly decode: (fa: FA) => option_.Option<TI> |
| 2280 | readonly encode: (o: option_.Option<TI>) => FA |
| 2281 | } |
| 2282 | ): PropertySignature<"?:", TA, never, ":", FI, false, FR | TR> => |
| 2283 | makePropertySignature( |
| 2284 | new PropertySignatureTransformation( |
| 2285 | new FromPropertySignature(from.ast, false, true, {}, undefined), |
| 2286 | new ToPropertySignature(to.ast, true, true, {}, undefined), |
| 2287 | option_.flatMap(options.decode), |
| 2288 | (o) => option_.some(options.encode(o)) |
| 2289 | ) |
| 2290 | ) |
| 2291 | |
| 2292 | /** |
| 2293 | * Converts an optional property to another optional property through a transformation `Option -> Option`. |
nothing calls this directly
no test coverage detected