Skip to main content

Class: ArrayValidator<T, I>

Extends

Type parameters

Type parameterValue
T extends unknown[]-
IT[number]

Constructors

new ArrayValidator()

new ArrayValidator<T, I>(validator: BaseValidator<I>, validatorOptions: ValidatorOptions, constraints: readonly IConstraint<T, T>[]): ArrayValidator<T, I>

Parameters

ParameterTypeDefault value
validatorBaseValidator<I>undefined
validatorOptionsValidatorOptions{}
constraintsreadonly IConstraint<T, T>[][]

Returns

ArrayValidator<T, I>

Overrides

BaseValidator . constructor

Source

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

Properties

constraints

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

Inherited from

BaseValidator . constraints

Source

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


description?

optional description: string

Inherited from

BaseValidator . description

Source

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


isValidationEnabled

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

Inherited from

BaseValidator . isValidationEnabled

Source

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


parent?

protected optional parent: object

Inherited from

BaseValidator . parent

Source

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


validator

private readonly validator: BaseValidator<I>

Source

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


validatorOptions

protected validatorOptions: ValidatorOptions

Inherited from

BaseValidator . validatorOptions

Source

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

Accessors

shouldRunConstraints

get protected shouldRunConstraints(): boolean

Returns

boolean

Source

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

Methods

addConstraint()

protected addConstraint(constraint: IConstraint<T, T>, validatorOptions: ValidatorOptions): this

Parameters

ParameterType
constraintIConstraint<T, T>
validatorOptionsValidatorOptions

Returns

this

Inherited from

BaseValidator . addConstraint

Source

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


array()

array(options: ValidatorOptions): ArrayValidator<T[], T>

Parameters

ParameterType
optionsValidatorOptions

Returns

ArrayValidator<T[], T>

Inherited from

BaseValidator . array

Source

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


clone()

protected clone(): this

Returns

this

Overrides

BaseValidator . clone

Source

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


default()

default(value: Exclude<T, undefined> | () => Exclude<T, undefined>, options: ValidatorOptions): DefaultValidator <Exclude<T, undefined>>

Parameters

ParameterType
valueExclude<T, undefined> | () => Exclude<T, undefined>
optionsValidatorOptions

Returns

DefaultValidator <Exclude<T, undefined>>

Inherited from

BaseValidator . default

Source

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


describe()

describe(description: string): this

Parameters

ParameterType
descriptionstring

Returns

this

Inherited from

BaseValidator . describe

Source

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


getValidationEnabled()

getValidationEnabled(): null | boolean

Returns

null | boolean

Inherited from

BaseValidator . getValidationEnabled

Source

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


handle()

protected handle(values: unknown): Result<T, ValidationError | CombinedPropertyError>

Parameters

ParameterType
valuesunknown

Returns

Result<T, ValidationError | CombinedPropertyError>

Overrides

BaseValidator . handle

Source

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


is()

is<R>(value: unknown): value is R

Type parameters

Type parameterValue
R extends unknown[]T

Parameters

ParameterType
valueunknown

Returns

value is R

Inherited from

BaseValidator . is

Source

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


lengthEqual()

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

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthGreaterThan()

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

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthGreaterThanOrEqual()

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

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthLessThan()

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

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthLessThanOrEqual()

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

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthNotEqual()

lengthNotEqual<N>(length: N, options: ValidatorOptions): ArrayValidator <[...Tuple<I, N>[]], [...Tuple<I, N>[]][number]>

Type parameters

Type parameter
N extends number

Parameters

ParameterType
lengthN
optionsValidatorOptions

Returns

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

Source

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


lengthRange()

lengthRange<S, E>(start: S, endBefore: E, options: ValidatorOptions): 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

Type parameter
S extends number
E extends number

Parameters

ParameterType
startS
endBeforeE
optionsValidatorOptions

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]>

Source

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


lengthRangeExclusive()

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

Type parameters

Type parameter
S extends number
E extends number

Parameters

ParameterType
startAfterS
endBeforeE
optionsValidatorOptions

Returns

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

Source

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


lengthRangeInclusive()

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

Type parameters

Type parameter
S extends number
E extends number

Parameters

ParameterType
startAtS
endAtE
optionsValidatorOptions

Returns

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

Source

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


nullable()

nullable(options: ValidatorOptions): UnionValidator<null | T>

Parameters

ParameterType
optionsValidatorOptions

Returns

UnionValidator<null | T>

Inherited from

BaseValidator . nullable

Source

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


nullish()

nullish(options: ValidatorOptions): UnionValidator<undefined | null | T>

Parameters

ParameterType
optionsValidatorOptions

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator . nullish

Source

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


optional()

optional(options: ValidatorOptions): UnionValidator<undefined | T>

Parameters

ParameterType
optionsValidatorOptions

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator . optional

Source

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


or()

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

Type parameters

Type parameter
O

Parameters

ParameterType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T | O>

Inherited from

BaseValidator . or

Source

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


parse()

parse<R>(value: unknown): R

Type parameters

Type parameterValue
R extends unknown[]T

Parameters

ParameterType
valueunknown

Returns

R

Inherited from

BaseValidator . parse

Source

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


reshape()

reshape(cb, options)

reshape(cb: (input: T) => Result<T, Error>, options?: ValidatorOptions): this

Parameters
ParameterType
cb(input: T) => Result<T, Error>
options?ValidatorOptions
Returns

this

Inherited from

BaseValidator . reshape

Source

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

reshape(cb, options)

reshape<R, O>(cb: (input: T) => R, options?: ValidatorOptions): BaseValidator<O>

Type parameters
Type parameterValue
R extends Result<unknown, Error>-
OInferResultType<R>
Parameters
ParameterType
cb(input: T) => R
options?ValidatorOptions
Returns

BaseValidator<O>

Inherited from

BaseValidator . reshape

Source

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


run()

run(value: unknown): Result<T, BaseError>

Parameters

ParameterType
valueunknown

Returns

Result<T, BaseError>

Inherited from

BaseValidator . run

Source

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


set()

set(options: ValidatorOptions): SetValidator<T>

Parameters

ParameterType
optionsValidatorOptions

Returns

SetValidator<T>

Inherited from

BaseValidator . set

Source

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


setParent()

setParent(parent: object): this

Parameters

ParameterType
parentobject

Returns

this

Inherited from

BaseValidator . setParent

Source

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


setValidationEnabled()

setValidationEnabled(isValidationEnabled: null | boolean | () => boolean): this

Sets if the validator should also run constraints or just do basic checks.

Parameters

ParameterTypeDescription
isValidationEnablednull | boolean | () => booleanWhether this validator should be enabled or disabled. You can pass boolean or a function returning boolean which will be called just before parsing. Set to null to go off of the global configuration.

Returns

this

Inherited from

BaseValidator . setValidationEnabled

Source

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


transform()

transform(cb, options)

transform(cb: (value: T) => T, options?: ValidatorOptions): this

Parameters
ParameterType
cb(value: T) => T
options?ValidatorOptions
Returns

this

Inherited from

BaseValidator . transform

Source

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

transform(cb, options)

transform<O>(cb: (value: T) => O, options?: ValidatorOptions): BaseValidator<O>

Type parameters
Type parameter
O
Parameters
ParameterType
cb(value: T) => O
options?ValidatorOptions
Returns

BaseValidator<O>

Inherited from

BaseValidator . transform

Source

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


unique()

unique(options: ValidatorOptions): this

Parameters

ParameterType
optionsValidatorOptions

Returns

this

Source

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


when()

when<Key, This>(key: Key, options: WhenOptions<This, Key>, validatorOptions?: ValidatorOptions): this

Type parameters

Type parameterValue
Key extends WhenKey-
This extends BaseValidator<any>ArrayValidator<T, I>

Parameters

ParameterType
keyKey
optionsWhenOptions<This, Key>
validatorOptions?ValidatorOptions

Returns

this

Inherited from

BaseValidator . when

Source

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