Skip to main content

Class: Shapes

Defined in: projects/shapeshift/src/lib/Shapes.ts:29

Constructors

new Shapes()

new Shapes(): Shapes

Returns

Shapes

Methods

any()

any(options?: ValidatorOptions): PassthroughValidator<any>

Defined in: projects/shapeshift/src/lib/Shapes.ts:66

Parameters

ParameterType
options?ValidatorOptions

Returns

PassthroughValidator<any>


array()

Call Signature

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

Defined in: projects/shapeshift/src/lib/Shapes.ts:105

Type Parameters
Type Parameter
T
Parameters
ParameterType
validatorBaseValidator<T>
options?ValidatorOptions
Returns

ArrayValidator<T[], T>

Call Signature

array<T>(validator: BaseValidator<T[number]>, options?: ValidatorOptions): ArrayValidator<T, T[number]>

Defined in: projects/shapeshift/src/lib/Shapes.ts:106

Type Parameters
Type Parameter
T extends unknown[]
Parameters
ParameterType
validatorBaseValidator<T[number]>
options?ValidatorOptions
Returns

ArrayValidator<T, T[number]>


bigint()

bigint(options?: ValidatorOptions): BigIntValidator<bigint>

Defined in: projects/shapeshift/src/lib/Shapes.ts:38

Parameters

ParameterType
options?ValidatorOptions

Returns

BigIntValidator<bigint>


bigInt64Array()

bigInt64Array(options?: ValidatorOptions): TypedArrayValidator<BigInt64Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:151

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<BigInt64Array>


bigUint64Array()

bigUint64Array(options?: ValidatorOptions): TypedArrayValidator<BigUint64Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:155

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<BigUint64Array>


boolean()

boolean(options?: ValidatorOptions): BooleanValidator

Defined in: projects/shapeshift/src/lib/Shapes.ts:42

Parameters

ParameterType
options?ValidatorOptions

Returns

BooleanValidator


date()

date(options?: ValidatorOptions): DateValidator

Defined in: projects/shapeshift/src/lib/Shapes.ts:46

Parameters

ParameterType
options?ValidatorOptions

Returns

DateValidator


enum()

enum<T>(values: readonly T[], options?: ValidatorOptions): UnionValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:78

Type Parameters

Type Parameter
T

Parameters

ParameterType
valuesreadonly T[]
options?ValidatorOptions

Returns

UnionValidator<T>


float32Array()

float32Array(options?: ValidatorOptions): TypedArrayValidator<Float32Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:143

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Float32Array>


float64Array()

float64Array(options?: ValidatorOptions): TypedArrayValidator<Float64Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:147

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Float64Array>


instance()

instance<T>(expected: Constructor<T>, options?: ValidatorOptions): InstanceValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:97

Type Parameters

Type Parameter
T

Parameters

ParameterType
expectedConstructor<T>
options?ValidatorOptions

Returns

InstanceValidator<T>


int16Array()

int16Array(options?: ValidatorOptions): TypedArrayValidator<Int16Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:127

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Int16Array>


int32Array()

int32Array(options?: ValidatorOptions): TypedArrayValidator<Int32Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:135

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Int32Array>


int8Array()

int8Array(options?: ValidatorOptions): TypedArrayValidator<Int8Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:115

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Int8Array>


lazy()

lazy<T>(validator: (value: unknown) => T, options?: ValidatorOptions): LazyValidator<T, Unwrap<T>>

Defined in: projects/shapeshift/src/lib/Shapes.ts:175

Type Parameters

Type Parameter
T extends BaseValidator<unknown>

Parameters

ParameterType
validator(value: unknown) => T
options?ValidatorOptions

Returns

LazyValidator<T, Unwrap<T>>


literal()

literal<T>(value: T, options?: object): BaseValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:89

Type Parameters

Type Parameter
T

Parameters

ParameterType
valueT
options?{ dateOptions: ValidatorOptions; equalsOptions: ValidatorOptions; }
options.dateOptions?ValidatorOptions
options.equalsOptions?ValidatorOptions

Returns

BaseValidator<T>


map()

map<T, U>(keyValidator: BaseValidator<T>, valueValidator: BaseValidator<U>, options?: ValidatorOptions): MapValidator<T, U>

Defined in: projects/shapeshift/src/lib/Shapes.ts:171

Type Parameters

Type Parameter
T
U

Parameters

ParameterType
keyValidatorBaseValidator<T>
valueValidatorBaseValidator<U>
options?ValidatorOptions

Returns

MapValidator<T, U>


nativeEnum()

nativeEnum<T>(enumShape: T, options?: ValidatorOptions): NativeEnumValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:85

Type Parameters

Type Parameter
T extends NativeEnumLike

Parameters

ParameterType
enumShapeT
options?ValidatorOptions

Returns

NativeEnumValidator<T>


never()

never(options?: ValidatorOptions): NeverValidator

Defined in: projects/shapeshift/src/lib/Shapes.ts:74

Parameters

ParameterType
options?ValidatorOptions

Returns

NeverValidator


null()

null(options?: ValidatorOptions): BaseValidator<null>

Defined in: projects/shapeshift/src/lib/Shapes.ts:58

Parameters

ParameterType
options?ValidatorOptions

Returns

BaseValidator<null>


nullish()

nullish(options?: ValidatorOptions): NullishValidator

Defined in: projects/shapeshift/src/lib/Shapes.ts:62

Parameters

ParameterType
options?ValidatorOptions

Returns

NullishValidator


number()

number(options?: ValidatorOptions): NumberValidator<number>

Defined in: projects/shapeshift/src/lib/Shapes.ts:34

Parameters

ParameterType
options?ValidatorOptions

Returns

NumberValidator<number>


object()

object<T>(shape: MappedObjectValidator<T>, options?: ValidatorOptions): ObjectValidator<T, UndefinedToOptional<T>>

Defined in: projects/shapeshift/src/lib/Shapes.ts:50

Type Parameters

Type Parameter
T extends object

Parameters

ParameterType
shapeMappedObjectValidator<T>
options?ValidatorOptions

Returns

ObjectValidator<T, UndefinedToOptional<T>>


record()

record<T>(validator: BaseValidator<T>, options?: ValidatorOptions): RecordValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:167

Type Parameters

Type Parameter
T

Parameters

ParameterType
validatorBaseValidator<T>
options?ValidatorOptions

Returns

RecordValidator<T>


set()

set<T>(validator: BaseValidator<T>, options?: ValidatorOptions): SetValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:163

Type Parameters

Type Parameter
T

Parameters

ParameterType
validatorBaseValidator<T>
options?ValidatorOptions

Returns

SetValidator<T>


string()

string(options?: ValidatorOptions): StringValidator<string>

Defined in: projects/shapeshift/src/lib/Shapes.ts:30

Parameters

ParameterType
options?ValidatorOptions

Returns

StringValidator<string>


tuple()

tuple<T>(validators: [...T[]], options?: ValidatorOptions): TupleValidator<UnwrapTuple<T>>

Defined in: projects/shapeshift/src/lib/Shapes.ts:159

Type Parameters

Type Parameter
T extends BaseValidator<any>[]

Parameters

ParameterType
validators[...T[]]
options?ValidatorOptions

Returns

TupleValidator<UnwrapTuple<T>>


typedArray()

typedArray<T>(type: "Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray", options?: ValidatorOptions): TypedArrayValidator<T>

Defined in: projects/shapeshift/src/lib/Shapes.ts:111

Type Parameters

Type Parameter
T extends TypedArray

Parameters

ParameterTypeDefault value
type"Int8Array" | "Uint8Array" | "Uint8ClampedArray" | "Int16Array" | "Uint16Array" | "Int32Array" | "Uint32Array" | "Float32Array" | "Float64Array" | "BigInt64Array" | "BigUint64Array" | "TypedArray"'TypedArray'
options?ValidatorOptionsundefined

Returns

TypedArrayValidator<T>


uint16Array()

uint16Array(options?: ValidatorOptions): TypedArrayValidator<Uint16Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:131

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Uint16Array>


uint32Array()

uint32Array(options?: ValidatorOptions): TypedArrayValidator<Uint32Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:139

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Uint32Array>


uint8Array()

uint8Array(options?: ValidatorOptions): TypedArrayValidator<Uint8Array>

Defined in: projects/shapeshift/src/lib/Shapes.ts:119

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Uint8Array>


uint8ClampedArray()

uint8ClampedArray(options?: ValidatorOptions): TypedArrayValidator<Uint8ClampedArray>

Defined in: projects/shapeshift/src/lib/Shapes.ts:123

Parameters

ParameterType
options?ValidatorOptions

Returns

TypedArrayValidator<Uint8ClampedArray>


undefined()

undefined(options?: ValidatorOptions): BaseValidator<undefined>

Defined in: projects/shapeshift/src/lib/Shapes.ts:54

Parameters

ParameterType
options?ValidatorOptions

Returns

BaseValidator<undefined>


union()

union<T>(validators: T, options?: ValidatorOptions): UnionValidator<Unwrap<T[number]>>

Defined in: projects/shapeshift/src/lib/Shapes.ts:101

Type Parameters

Type Parameter
T extends BaseValidator<any>[]

Parameters

ParameterType
validatorsT
options?ValidatorOptions

Returns

UnionValidator<Unwrap<T[number]>>


unknown()

unknown(options?: ValidatorOptions): PassthroughValidator<unknown>

Defined in: projects/shapeshift/src/lib/Shapes.ts:70

Parameters

ParameterType
options?ValidatorOptions

Returns

PassthroughValidator<unknown>