(
from: Schema<FA, FI, FR>,
to: Schema<TA, TI, TR>,
options: {
readonly decode: (o: option_.Option<FA>) => TI
readonly encode: (ti: TI) => option_.Option<FA>
}
)
| 2247 | * @since 3.10.0 |
| 2248 | */ |
| 2249 | export const optionalToRequired = <FA, FI, FR, TA, TI, TR>( |
| 2250 | from: Schema<FA, FI, FR>, |
| 2251 | to: Schema<TA, TI, TR>, |
| 2252 | options: { |
| 2253 | readonly decode: (o: option_.Option<FA>) => TI |
| 2254 | readonly encode: (ti: TI) => option_.Option<FA> |
| 2255 | } |
| 2256 | ): PropertySignature<":", TA, never, "?:", FI, false, FR | TR> => |
| 2257 | makePropertySignature( |
| 2258 | new PropertySignatureTransformation( |
| 2259 | new FromPropertySignature(from.ast, true, true, {}, undefined), |
| 2260 | new ToPropertySignature(to.ast, false, true, {}, undefined), |
| 2261 | (o) => option_.some(options.decode(o)), |
| 2262 | option_.flatMap(options.encode) |
| 2263 | ) |
| 2264 | ) |
| 2265 | |
| 2266 | /** |
| 2267 | * Converts an optional property to a required one through a transformation `Type -> Option`. |
no test coverage detected