Search


Search something to see results

array

Type Parameters

  • T

Parameters

Returns ArraySchema<T>

const schema = x.array(x.string)
const schema = x.array(x.string)
schema.item // -> x.string
const schema = pipe(x.array(), x.nonEmpty())
const schema = pipe(x.array(), x.nonEmpty('requires 1+ elements'))

const schema = pipe(x.array(), x.size({ min: 3 }))
const schema = pipe(x.array(), x.size({ min: 3, reason: '' }))
const schema = pipe(x.array(), x.size({ max: 10 }))
const schema = pipe(x.array(), x.size({ max: 10, reason: '' }))

const schema = pipe(x.array(), x.size({ min: 3, max: 10 }))
const schema = pipe(x.array(), x.size({ min: 3, max: 10, reason: '' }))
const arrayOfMinimumFiveUpperCaseStrings = pipe(
x.string,
x.nonEmpty('this string must have some content'),
x.map((str) => str.toUpperCase()),
x.array,
x.size({ min: 5, reason: 'requires 5+ elements' }),
)