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: readonlyIConstraint<T,T>[]):TypedArrayValidator<T>
Parameters
| Parameter | Type | Default value |
|---|---|---|
type | "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray" | undefined |
validatorOptions | ValidatorOptions | {} |
constraints | readonly IConstraint<T, T>[] | [] |
Returns
Overrides
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:32
Properties
constraints
protectedconstraints: readonlyIConstraint<T,T>[] =[]
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:19
description?
optionaldescription:string
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:16
isValidationEnabled
protectedisValidationEnabled:null|boolean| () =>boolean=null
Inherited from
BaseValidator . isValidationEnabled
Source
projects/shapeshift/src/validators/BaseValidator.ts:20
parent?
protectedoptionalparent:object
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:18
type
privatereadonlytype:"Int8Array"|"Uint8Array"|"Uint8ClampedArray"|"Int16Array"|"Uint16Array"|"Int32Array"|"Uint32Array"|"Float32Array"|"Float64Array"|"BigInt64Array"|"BigUint64Array"|"TypedArray"
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:30
validatorOptions
protectedvalidatorOptions:ValidatorOptions
Inherited from
BaseValidator . validatorOptions
Source
projects/shapeshift/src/validators/BaseValidator.ts:17
Accessors
shouldRunConstraints
getprotectedshouldRunConstraints():boolean
Returns
boolean
Source
projects/shapeshift/src/validators/BaseValidator.ts:143
Methods
addConstraint()
protectedaddConstraint(constraint:IConstraint<T,T>,validatorOptions:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
constraint | IConstraint<T, T> |
validatorOptions | ValidatorOptions |
Returns
this
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:155
array()
array(
options:ValidatorOptions):ArrayValidator<T[],T>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
ArrayValidator<T[], T>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:44
byteLengthEqual()
byteLengthEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:53
byteLengthGreaterThan()
byteLengthGreaterThan(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:45
byteLengthGreaterThanOrEqual()
byteLengthGreaterThanOrEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:49
byteLengthLessThan()
byteLengthLessThan(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:37
byteLengthLessThanOrEqual()
byteLengthLessThanOrEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:41
byteLengthNotEqual()
byteLengthNotEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:57
byteLengthRange()
byteLengthRange(
start:number,endBefore:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
start | number |
endBefore | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:61
byteLengthRangeExclusive()
byteLengthRangeExclusive(
startAfter:number,endBefore:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
startAfter | number |
endBefore | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:69
byteLengthRangeInclusive()
byteLengthRangeInclusive(
startAt:number,endAt:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
startAt | number |
endAt | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:65
clone()
protectedclone():this
Returns
this
Overrides
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:109
default()
default(
value:Exclude<T,undefined> | () =>Exclude<T,undefined>,options:ValidatorOptions):DefaultValidator<Exclude<T,undefined>>
Parameters
| Parameter | Type |
|---|---|
value | Exclude<T, undefined> | () => Exclude<T, undefined> |
options | ValidatorOptions |
Returns
DefaultValidator <Exclude<T, undefined>>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:81
describe()
describe(
description:string):this
Parameters
| Parameter | Type |
|---|---|
description | string |
Returns
this
Inherited from
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()
protectedhandle(value:unknown):Result<T,ValidationError>
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
Overrides
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:113
is()
is<
R>(value:unknown):value is R
Type parameters
| Type parameter | Value |
|---|---|
R extends TypedArray | T |
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
value is R
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:124
lengthEqual()
lengthEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:89
lengthGreaterThan()
lengthGreaterThan(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:81
lengthGreaterThanOrEqual()
lengthGreaterThanOrEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:85
lengthLessThan()
lengthLessThan(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:73
lengthLessThanOrEqual()
lengthLessThanOrEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:77
lengthNotEqual()
lengthNotEqual(
length:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
length | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:93
lengthRange()
lengthRange(
start:number,endBefore:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
start | number |
endBefore | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:97
lengthRangeExclusive()
lengthRangeExclusive(
startAfter:number,endBefore:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
startAfter | number |
endBefore | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:105
lengthRangeInclusive()
lengthRangeInclusive(
startAt:number,endAt:number,options:ValidatorOptions):TypedArrayValidator<T>
Parameters
| Parameter | Type |
|---|---|
startAt | number |
endAt | number |
options | ValidatorOptions |
Returns
Source
projects/shapeshift/src/validators/TypedArrayValidator.ts:101
nullable()
nullable(
options:ValidatorOptions):UnionValidator<null|T>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<null | T>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:36
nullish()
nullish(
options:ValidatorOptions):UnionValidator<undefined|null|T>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<undefined | null | T>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:40
optional()
optional(
options:ValidatorOptions):UnionValidator<undefined|T>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
UnionValidator<undefined | T>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:32
or()
or<
O>(...predicates: readonlyBaseValidator<O>[]):UnionValidator<T|O>
Type parameters
| Type parameter |
|---|
O |
Parameters
| Parameter | Type |
|---|---|
...predicates | readonly BaseValidator<O>[] |
Returns
UnionValidator<T | O>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:52
parse()
parse<
R>(value:unknown):R
Type parameters
| Type parameter | Value |
|---|---|
R extends TypedArray | T |
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
R
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:114
reshape()
reshape(cb, options)
reshape(
cb: (input:T) =>Result<T,Error>,options?:ValidatorOptions):this
Parameters
| Parameter | Type |
|---|---|
cb | (input: T) => Result<T, Error> |
options? | ValidatorOptions |
Returns
this
Inherited from
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 parameter | Value |
|---|---|
R extends Result<unknown, Error> | - |
O | InferResultType<R> |
Parameters
| Parameter | Type |
|---|---|
cb | (input: T) => R |
options? | ValidatorOptions |
Returns
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:68
run()
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:102
set()
set(
options:ValidatorOptions):SetValidator<T>
Parameters
| Parameter | Type |
|---|---|
options | ValidatorOptions |
Returns
SetValidator<T>
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:48
setParent()
setParent(
parent:object):this
Parameters
| Parameter | Type |
|---|---|
parent | object |
Returns
this
Inherited from
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
| Parameter | Type | Description |
|---|---|---|
isValidationEnabled | null | boolean | () => boolean | Whether 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
| Parameter | Type |
|---|---|
cb | (value: T) => T |
options? | ValidatorOptions |
Returns
this
Inherited from
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
| Parameter | Type |
|---|---|
cb | (value: T) => O |
options? | ValidatorOptions |
Returns
Inherited from
Source
projects/shapeshift/src/validators/BaseValidator.ts:57
when()
when<
Key,This>(key:Key,options:WhenOptions<This,Key>,validatorOptions?:ValidatorOptions):this
Type parameters
| Type parameter | Value |
|---|---|
Key extends WhenKey | - |
This extends BaseValidator<any> | TypedArrayValidator<T> |
Parameters
| Parameter | Type |
|---|---|
key | Key |
options | WhenOptions<This, Key> |
validatorOptions? | ValidatorOptions |
Returns
this