Skip to main content

Class: TypedArrayValidator<T>

Extends​

Type Parameters​

Type Parameter
T extends TypedArray

Constructors​

new TypedArrayValidator()​

new TypedArrayValidator<T>(type: "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray", validatorOptions: ValidatorOptions, constraints: readonly IConstraint<T, T>[]): TypedArrayValidator<T>

Parameters​

ParameterTypeDefault value
type"Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray"undefined
validatorOptionsValidatorOptions{}
constraintsreadonly IConstraint<T, T>[][]

Returns​

TypedArrayValidator<T>

Overrides​

BaseValidator.constructor

Defined in​

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

Properties​

constraints​

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

Inherited from​

BaseValidator.constraints

Defined in​

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


description?​

optional description: string

Inherited from​

BaseValidator.description

Defined in​

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


isValidationEnabled​

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

Inherited from​

BaseValidator.isValidationEnabled

Defined in​

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


parent?​

protected optional parent: object

Inherited from​

BaseValidator.parent

Defined in​

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


validatorOptions​

protected validatorOptions: ValidatorOptions

Inherited from​

BaseValidator.validatorOptions

Defined in​

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

Accessors​

shouldRunConstraints​

Get Signature​

get protected shouldRunConstraints(): boolean

Returns​

boolean

Inherited from​

BaseValidator.shouldRunConstraints

Defined in​

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

Defined in​

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

Defined in​

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


byteLengthEqual()​

byteLengthEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:53


byteLengthGreaterThan()​

byteLengthGreaterThan(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:45


byteLengthGreaterThanOrEqual()​

byteLengthGreaterThanOrEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:49


byteLengthLessThan()​

byteLengthLessThan(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


byteLengthLessThanOrEqual()​

byteLengthLessThanOrEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


byteLengthNotEqual()​

byteLengthNotEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


byteLengthRange()​

byteLengthRange(start: number, endBefore: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startnumber
endBeforenumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


byteLengthRangeExclusive()​

byteLengthRangeExclusive(startAfter: number, endBefore: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startAfternumber
endBeforenumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:69


byteLengthRangeInclusive()​

byteLengthRangeInclusive(startAt: number, endAt: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startAtnumber
endAtnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


clone()​

protected clone(): this

Returns​

this

Overrides​

BaseValidator.clone

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:109


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

Defined in​

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


describe()​

describe(description: string): this

Parameters​

ParameterType
descriptionstring

Returns​

this

Inherited from​

BaseValidator.describe

Defined in​

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


getValidationEnabled()​

getValidationEnabled(): null | boolean

Returns​

null | boolean

Inherited from​

BaseValidator.getValidationEnabled

Defined in​

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


handle()​

protected handle(value: unknown): Result<T, ValidationError>

Parameters​

ParameterType
valueunknown

Returns​

Result<T, ValidationError>

Overrides​

BaseValidator.handle

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:113


is()​

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

Type Parameters​

Type ParameterDefault type
R extends TypedArrayT

Parameters​

ParameterType
valueunknown

Returns​

value is R

Inherited from​

BaseValidator.is

Defined in​

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


lengthEqual()​

lengthEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


lengthGreaterThan()​

lengthGreaterThan(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


lengthGreaterThanOrEqual()​

lengthGreaterThanOrEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:85


lengthLessThan()​

lengthLessThan(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


lengthLessThanOrEqual()​

lengthLessThanOrEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:77


lengthNotEqual()​

lengthNotEqual(length: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
lengthnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


lengthRange()​

lengthRange(start: number, endBefore: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startnumber
endBeforenumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

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


lengthRangeExclusive()​

lengthRangeExclusive(startAfter: number, endBefore: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startAfternumber
endBeforenumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:105


lengthRangeInclusive()​

lengthRangeInclusive(startAt: number, endAt: number, options: ValidatorOptions): TypedArrayValidator<T>

Parameters​

ParameterType
startAtnumber
endAtnumber
optionsValidatorOptions

Returns​

TypedArrayValidator<T>

Defined in​

projects/shapeshift/src/validators/TypedArrayValidator.ts:101


nullable()​

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

Parameters​

ParameterType
optionsValidatorOptions

Returns​

UnionValidator<null | T>

Inherited from​

BaseValidator.nullable

Defined in​

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

Defined in​

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

Defined in​

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

Defined in​

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


parse()​

parse<R>(value: unknown): R

Type Parameters​

Type ParameterDefault type
R extends TypedArrayT

Parameters​

ParameterType
valueunknown

Returns​

R

Inherited from​

BaseValidator.parse

Defined in​

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

Defined in​

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

reshape(cb, options)​

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

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

BaseValidator<O>

Inherited from​

BaseValidator.reshape

Defined in​

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

Defined in​

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


set()​

set(options: ValidatorOptions): SetValidator<T>

Parameters​

ParameterType
optionsValidatorOptions

Returns​

SetValidator<T>

Inherited from​

BaseValidator.set

Defined in​

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


setParent()​

setParent(parent: object): this

Parameters​

ParameterType
parentobject

Returns​

this

Inherited from​

BaseValidator.setParent

Defined in​

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

Defined in​

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

Defined in​

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

Defined in​

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


when()​

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

Type Parameters​

Type ParameterDefault type
Key extends WhenKey-
This extends BaseValidator<any>TypedArrayValidator<T>

Parameters​

ParameterType
keyKey
optionsWhenOptions<This, Key>
validatorOptions?ValidatorOptions

Returns​

this

Inherited from​

BaseValidator.when

Defined in​

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