(schema: S)
| 4723 | * @since 3.10.0 |
| 4724 | */ |
| 4725 | export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> { |
| 4726 | return Union([schema, ArraySchema(schema)]).pipe(decodeTo( |
| 4727 | ArraySchema(toType(schema)), |
| 4728 | SchemaTransformation.transform({ |
| 4729 | decode: Arr.ensure, |
| 4730 | encode: (array) => array.length === 1 ? array[0] : array |
| 4731 | }) |
| 4732 | )) |
| 4733 | } |
| 4734 | |
| 4735 | /** |
| 4736 | * Type-level representation returned by {@link UniqueArray}. |