Skip to main content

Class: ArrayValidator<T, I>

Type parameters

NameType
Textends unknown[]
IT[number]

Hierarchy

Constructors

constructor

new ArrayValidator<T, I>(validator, constraints?)

Type parameters

NameType
Textends unknown[]
IT[number]

Parameters

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

Overrides

BaseValidator.constructor

Defined in

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

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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


isValidationEnabled

Protected isValidationEnabled: null | boolean | () => boolean = null

Inherited from

BaseValidator.isValidationEnabled

Defined in

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


validator

Private Readonly validator: BaseValidator<I>

Defined in

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

Accessors

array

get array(): ArrayValidator<T[], T>

Returns

ArrayValidator<T[], T>

Inherited from

BaseValidator.array

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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


shouldRunConstraints

Protected get shouldRunConstraints(): boolean

Returns

boolean

Inherited from

BaseValidator.shouldRunConstraints

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): ArrayValidator<T, I>

Parameters

NameType
constraintIConstraint<T, T>

Returns

ArrayValidator<T, I>

Inherited from

BaseValidator.addConstraint

Defined in

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


clone

Protected clone(): ArrayValidator<T, I>

Returns

ArrayValidator<T, I>

Overrides

BaseValidator.clone

Defined in

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


default

default(value): DefaultValidator<Exclude<T, undefined>>

Parameters

NameType
valueExclude<T, undefined> | () => Exclude<T, undefined>

Returns

DefaultValidator<Exclude<T, undefined>>

Inherited from

BaseValidator.default

Defined in

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


getValidationEnabled

getValidationEnabled(): null | boolean

Returns

null | boolean

Inherited from

BaseValidator.getValidationEnabled

Defined in

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


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:77


lengthEqual

lengthEqual<N>(length): ArrayValidator<[...Tuple<I, N>[]], [...Tuple<I, N>[]][`number`]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

ArrayValidator<[...Tuple<I, N>[]], [...Tuple<I, N>[]][`number`]>

Defined in

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


lengthGreaterThan

lengthGreaterThan<N>(length): ArrayValidator<[...Tuple<I, N>[], I, ...T[]], [...Tuple<I, N>[], I, ...T[]][`number`]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

ArrayValidator<[...Tuple<I, N>[], I, ...T[]], [...Tuple<I, N>[], I, ...T[]][`number`]>

Defined in

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


lengthGreaterThanOrEqual

lengthGreaterThanOrEqual<N>(length): ArrayValidator<[...Tuple<I, N>[], ...T[]], [...Tuple<I, N>[], ...T[]][`number`]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

ArrayValidator<[...Tuple<I, N>[], ...T[]], [...Tuple<I, N>[], ...T[]][`number`]>

Defined in

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


lengthLessThan

lengthLessThan<N>(length): ArrayValidator<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, N>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, N>[]]>>[number]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

ArrayValidator<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, N>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, N>[]]>>[number]>

Defined in

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


lengthLessThanOrEqual

lengthLessThanOrEqual<N>(length): ArrayValidator<ExpandSmallerTuples<[...Tuple<I, N>[]]>, ExpandSmallerTuples<[...Tuple<I, N>[]]>[number]>

Type parameters

NameType
Nextends number

Parameters

NameType
lengthN

Returns

ArrayValidator<ExpandSmallerTuples<[...Tuple<I, N>[]]>, ExpandSmallerTuples<[...Tuple<I, N>[]]>[number]>

Defined in

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


lengthNotEqual

lengthNotEqual(length): ArrayValidator<[...T[]], [...T[]][`number`]>

Parameters

NameType
lengthnumber

Returns

ArrayValidator<[...T[]], [...T[]][`number`]>

Defined in

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


lengthRange

lengthRange<S, E>(start, endBefore): ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>, Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>[number]>

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startS
endBeforeE

Returns

ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>, Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>[number]>

Defined in

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


lengthRangeExclusive

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

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startAfterS
endBeforeE

Returns

ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<[...Tuple<T, S>[]]>>, Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>[]]>>, ExpandSmallerTuples<[...Tuple<T, S>[]]>>[number]>

Defined in

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


lengthRangeInclusive

lengthRangeInclusive<S, E>(startAt, endAt): ArrayValidator<Exclude<ExpandSmallerTuples<[...Tuple<I, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>, Exclude<ExpandSmallerTuples<[...Tuple<I, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>[number]>

Type parameters

NameType
Sextends number
Eextends number

Parameters

NameType
startAtS
endAtE

Returns

ArrayValidator<Exclude<ExpandSmallerTuples<[...Tuple<I, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>, Exclude<ExpandSmallerTuples<[...Tuple<I, E>[]]>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>[]]>>>[number]>

Defined in

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


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:40


parse

parse<R>(value): R

Type parameters

NameType
Rextends unknown[] = T

Parameters

NameType
valueunknown

Returns

R

Inherited from

BaseValidator.parse

Defined in

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


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:54


setValidationEnabled

setValidationEnabled(isValidationEnabled): ArrayValidator<T, I>

Parameters

NameTypeDescription
isValidationEnablednull | boolean | () => boolean

Returns

ArrayValidator<T, I>

Inherited from

BaseValidator.setValidationEnabled

Defined in

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


transform

transform(cb): ArrayValidator<T, I>

Parameters

NameType
cb(value: T) => T

Returns

ArrayValidator<T, I>

Inherited from

BaseValidator.transform

Defined in

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

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:45