Skip to main content

Class: TypedArrayValidator<T>

Type parameters

NameType
Textends TypedArray

Hierarchy

Constructors

constructor

new TypedArrayValidator<T>(type, constraints?): TypedArrayValidator<T>

Type parameters

NameType
Textends TypedArray

Parameters

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

Returns

TypedArrayValidator<T>

Overrides

BaseValidator.constructor

Defined in

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

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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


description

Optional description: string

Inherited from

BaseValidator.description

Defined in

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


isValidationEnabled

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

Inherited from

BaseValidator.isValidationEnabled

Defined in

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


parent

Protected Optional parent: object

Inherited from

BaseValidator.parent

Defined in

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


type

Private Readonly type: "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray"

Defined in

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

Accessors

array

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

Returns

ArrayValidator<T[], T>

Inherited from

BaseValidator.array

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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


shouldRunConstraints

get shouldRunConstraints(): boolean

Returns

boolean

Inherited from

BaseValidator.shouldRunConstraints

Defined in

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

Methods

addConstraint

addConstraint(constraint): this

Parameters

NameType
constraintIConstraint<T, T>

Returns

this

Inherited from

BaseValidator.addConstraint

Defined in

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


byteLengthEqual

byteLengthEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthGreaterThan

byteLengthGreaterThan(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthGreaterThanOrEqual

byteLengthGreaterThanOrEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthLessThan

byteLengthLessThan(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthLessThanOrEqual

byteLengthLessThanOrEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthNotEqual

byteLengthNotEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthRange

byteLengthRange(start, endBefore): TypedArrayValidator<T>

Parameters

NameType
startnumber
endBeforenumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthRangeExclusive

byteLengthRangeExclusive(startAfter, endBefore): TypedArrayValidator<T>

Parameters

NameType
startAfternumber
endBeforenumber

Returns

TypedArrayValidator<T>

Defined in

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


byteLengthRangeInclusive

byteLengthRangeInclusive(startAt, endAt): TypedArrayValidator<T>

Parameters

NameType
startAtnumber
endAtnumber

Returns

TypedArrayValidator<T>

Defined in

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


clone

clone(): this

Returns

this

Overrides

BaseValidator.clone

Defined in

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


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


describe

describe(description): this

Parameters

NameType
descriptionstring

Returns

this

Inherited from

BaseValidator.describe

Defined in

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


getValidationEnabled

getValidationEnabled(): null | boolean

Returns

null | boolean

Inherited from

BaseValidator.getValidationEnabled

Defined in

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


handle

handle(value): Result<T, ValidationError>

Parameters

NameType
valueunknown

Returns

Result<T, ValidationError>

Overrides

BaseValidator.handle

Defined in

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


is

is<R>(value): value is R

Type parameters

NameType
Rextends TypedArray = T

Parameters

NameType
valueunknown

Returns

value is R

Inherited from

BaseValidator.is

Defined in

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


lengthEqual

lengthEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthGreaterThan

lengthGreaterThan(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthGreaterThanOrEqual

lengthGreaterThanOrEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthLessThan

lengthLessThan(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthLessThanOrEqual

lengthLessThanOrEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthNotEqual

lengthNotEqual(length): TypedArrayValidator<T>

Parameters

NameType
lengthnumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthRange

lengthRange(start, endBefore): TypedArrayValidator<T>

Parameters

NameType
startnumber
endBeforenumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthRangeExclusive

lengthRangeExclusive(startAfter, endBefore): TypedArrayValidator<T>

Parameters

NameType
startAfternumber
endBeforenumber

Returns

TypedArrayValidator<T>

Defined in

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


lengthRangeInclusive

lengthRangeInclusive(startAt, endAt): TypedArrayValidator<T>

Parameters

NameType
startAtnumber
endAtnumber

Returns

TypedArrayValidator<T>

Defined in

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


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


parse

parse<R>(value): R

Type parameters

NameType
Rextends TypedArray = T

Parameters

NameType
valueunknown

Returns

R

Inherited from

BaseValidator.parse

Defined in

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


reshape

reshape(cb): this

Parameters

NameType
cb(input: T) => Result<T, Error>

Returns

this

Inherited from

BaseValidator.reshape

Defined in

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

reshape<R, O>(cb): BaseValidator<O>

Type parameters

NameType
Rextends Result<unknown, Error>
OInferResultType<R>

Parameters

NameType
cb(input: T) => R

Returns

BaseValidator<O>

Inherited from

BaseValidator.reshape

Defined in

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


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


setParent

setParent(parent): this

Parameters

NameType
parentobject

Returns

this

Inherited from

BaseValidator.setParent

Defined in

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


setValidationEnabled

setValidationEnabled(isValidationEnabled): this

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

Parameters

NameTypeDescription
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:110


transform

transform(cb): this

Parameters

NameType
cb(value: T) => T

Returns

this

Inherited from

BaseValidator.transform

Defined in

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

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


when

when<Key, This>(key, options): this

Type parameters

NameType
Keyextends WhenKey
Thisextends BaseValidator<any> = TypedArrayValidator<T>

Parameters

NameType
keyKey
optionsWhenOptions<This, Key>

Returns

this

Inherited from

BaseValidator.when

Defined in

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