[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › nonEmptyArray

```ts
function nonEmptyArray<
  ParentType extends AnyType & {
    Output: readonly unknown[];
  },
>(
  parent: ValidateBrandParent<"NonEmptyArray", ParentType>,
): Type<"NonEmptyArray">;
```

Defined in: [packages/common/src/Type.ts:13306](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/common/src/Type.ts#L13306)

Adds non-empty validation to an existing array Type.

Narrows the Output to a [NonEmptyReadonlyArray](https://evolu.dev/docs/api-reference/common/Array/type-aliases/NonEmptyReadonlyArray) while preserving the
parent Type's constraints and brands, so functions that require a non-empty
array accept it without another check. Validation leaves the array unchanged.
For strings, use [minLength](https://evolu.dev/docs/api-reference/common/Type/functions/minLength).

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertOk,
  array,
  firstInArray,
  nonEmptyArray,
  String,
} from "@evolu/common";

const Tags = nonEmptyArray(array(String));

const tags = Tags.fromUnknown(["local-first", "offline"]);
assertOk(tags, ["local-first", "offline"]);
assertEqual(firstInArray(tags.value), "local-first");

const invalid = Tags.fromUnknown([]);
assertErr(invalid, { type: "NonEmptyArray", value: [] });
assertEqual(
  Tags.formatError(invalid.error),
  "The value [] must contain at least one item.",
);
```