Skip to main content

array

npm Package Size Security Scorecard CI

Use this schema to validate arrays with item-level validation.

import {array, string} from '@livon/schema';

const Tags = array({
name: 'Tags',
item: string().min(1),
});

const value = Tags.parse(['livon', 'schema']);

array.item can use any value schema from this section.
API schemas (api) are not valid as array item schemas.

Parameters

  • name (string, required): array schema name.
  • item (Schema<T>, required): item schema.
  • doc (SchemaDoc, optional): schema metadata attached to AST/doc output.

Chain API

  • No schema-specific chain methods.
  • Shared methods on current type T = item[]: optional(): Schema<T | undefined>, nullable(): Schema<T | null>, describe(doc: SchemaDoc): Schema<T>, refine(input): Schema<T>, before(hook): Schema<T>, after<U>(hook): Schema<U>, and<U>(other: Schema<U>, options?: {name?: string}): Schema<T & U>.