Skip to main content

Class: ArrayValidator<T>

Type parameters

Name
T

Hierarchy

Constructors

constructor

new ArrayValidator<T>(validator, constraints?)

Type parameters

Name
T

Parameters

NameTypeDefault value
validatorBaseValidator<T>undefined
constraintsreadonly IConstraint<T[], T[]>[][]

Overrides

BaseValidator.constructor

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:22

Properties

constraints

Protected constraints: readonly IConstraint<T[], T[]>[] = []

Inherited from

BaseValidator.constraints

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:11


validator

Private Readonly validator: BaseValidator<T>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:20

Accessors

array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.array

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:29


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:21


nullish

get nullish(): UnionValidator<undefined | null | T>

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:25


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:17


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:33

Methods

addConstraint

Protected addConstraint(constraint): ArrayValidator<T>

Parameters

NameType
constraintIConstraint<T[], T[]>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.addConstraint

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:73


clone

Protected clone(): ArrayValidator<T>

Returns

ArrayValidator<T>

Overrides

BaseValidator.clone

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:72


default

default(value): DefaultValidator<T[]>

Parameters

NameType
valueT[] | () => T[]

Returns

DefaultValidator<T[]>

Inherited from

BaseValidator.default

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:47


handle

Protected handle(values): Result<T[], CombinedPropertyError | ValidationError>

Parameters

NameType
valuesunknown

Returns

Result<T[], CombinedPropertyError | ValidationError>

Overrides

BaseValidator.handle

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:76


lengthEqual

lengthEqual<N>(length): BaseValidator<[...Tuple<T, N>[]]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

BaseValidator<[...Tuple<T, N>[]]>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:43


lengthGreaterThan

lengthGreaterThan<N>(length): BaseValidator<[...Tuple<T, N>[], T, ...T[]]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

BaseValidator<[...Tuple<T, N>[], T, ...T[]]>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:35


lengthGreaterThanOrEqual

lengthGreaterThanOrEqual<N>(length): BaseValidator<[...Tuple<T, N>[], ...T[]]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

BaseValidator<[...Tuple<T, N>[], ...T[]]>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:39


lengthLessThan

lengthLessThan<N>(length): BaseValidator<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, N>[]]>>>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

BaseValidator<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, N>[]]>>>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:27


lengthLessThanOrEqual

lengthLessThanOrEqual<N>(length): BaseValidator<ExpandSmallerTuples<[...Tuple<T, N>[]]>>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

BaseValidator<ExpandSmallerTuples<[...Tuple<T, N>[]]>>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:31


lengthNotEqual

lengthNotEqual(length): BaseValidator<T[]>

Parameters

NameType
lengthnumber

Returns

BaseValidator<T[]>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:47


lengthRange

lengthRange<S, E>(start, endBefore): BaseValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, S>[]]>>>>

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startS
endBeforeE

Returns

BaseValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, S>[]]>>>>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:51


lengthRangeExclusive

lengthRangeExclusive<S, E>(startAfter, endBefore): BaseValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, E>[]]>>, ExpandSmallerTuples<[...Tuple<T, S>[]]>>>

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startAfterS
endBeforeE

Returns

BaseValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, E>[]]>>, ExpandSmallerTuples<[...Tuple<T, S>[]]>>>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:65


lengthRangeInclusive

lengthRangeInclusive<S, E>(startAt, endAt): BaseValidator<Exclude<ExpandSmallerTuples<[...Tuple<T, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, S>[]]>>>>

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startAtS
endAtE

Returns

BaseValidator<Exclude<ExpandSmallerTuples<[...Tuple<T, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<T, S>[]]>>>>

Defined in

projects/shapeshift/src/validators/ArrayValidator.ts:58


or

or<O>(...predicates): UnionValidator<T[] | O>

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T[] | O>

Inherited from

BaseValidator.or

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:37


parse

parse(value): T[]

Parameters

NameType
valueunknown

Returns

T[]

Inherited from

BaseValidator.parse

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:63


run

run(value): Result<T[], BaseError>

Parameters

NameType
valueunknown

Returns

Result<T[], BaseError>

Inherited from

BaseValidator.run

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:51


transform

transform(cb): ArrayValidator<T>

Parameters

NameType
cb(value: T[]) => T[]

Returns

ArrayValidator<T>

Inherited from

BaseValidator.transform

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:41

transform<O>(cb): BaseValidator<O>

Type parameters

Name
O

Parameters

NameType
cb(value: T[]) => O

Returns

BaseValidator<O>

Inherited from

BaseValidator.transform

Defined in

projects/shapeshift/src/validators/BaseValidator.ts:42