From a0635712eabcc2382a34b6eb34c7899b8f994f0c Mon Sep 17 00:00:00 2001 From: Patrick Roza Date: Thu, 23 Apr 2026 17:19:00 +0200 Subject: [PATCH] an array that is not empty - simple --- packages/effect-app/src/Schema/ext.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/effect-app/src/Schema/ext.ts b/packages/effect-app/src/Schema/ext.ts index 76794bfc4..ecb46a553 100644 --- a/packages/effect-app/src/Schema/ext.ts +++ b/packages/effect-app/src/Schema/ext.ts @@ -15,6 +15,15 @@ type ProvidedCodec = S.Codec< Exclude > +export const NonEmptyArrayAsTuple: typeof S.NonEmptyArray = S.NonEmptyArray +export type NonEmptyArrayAsTuple = S.NonEmptyArray + +/** + * An array that is non empty. Non emptyness is confirmed on the container, not as the first element (unlike on tuples) + */ +export const NonEmptyArray = (valueSchema: ValueSchema) => + S.Array(valueSchema).pipe(S.check(S.isMinLength(1)), S.decodeTo(S.toType(S.NonEmptyArray(valueSchema)))) + // TODO: v4 migration - Date is no longer by default encoded to string. const DateString = S.String.annotate({