| 4826 | * @since 3.10.0 |
| 4827 | */ |
| 4828 | export function ArrayEnsure<S extends Constraint>(schema: S): ArrayEnsure<S> { |
| 4829 | const many = ArraySchema(schema) |
| 4830 | const to = ArraySchema(toType(schema)) |
| 4831 | const one = decodeTo( |
| 4832 | Tuple([Unknown]), |
| 4833 | SchemaTransformation.transform({ |
| 4834 | decode: (value) => [value] as const, |
| 4835 | encode: ([value]) => value |
| 4836 | }) |
| 4837 | )(schema) |
| 4838 | return make(Union([one, many]).pipe(decodeTo(to)).ast, { from: Union([schema, many]), to }) |
| 4839 | } |
| 4840 | /** |
| 4841 | * Type-level representation returned by {@link UniqueArray}. |
| 4842 | * |