Skip to main content

Class: NativeEnumValidator<T>

Type parameters

NameType
Textends NativeEnumLike

Hierarchy

Constructors

constructor

new NativeEnumValidator<T>(enumShape)

Type parameters

NameType
Textends NativeEnumLike

Parameters

NameType
enumShapeT

Overrides

BaseValidator.constructor

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:12

Properties

constraints

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

Inherited from

BaseValidator.constraints

Defined in

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


enumKeys

Private Readonly enumKeys: string[]

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:9


enumMapping

Private Readonly enumMapping: Map<string | number, T[keyof T]>

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:10


enumShape

Readonly enumShape: T

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:7


hasNumericElements

Readonly hasNumericElements: boolean = false

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:8

Accessors

array

get array(): ArrayValidator<T>

Returns

ArrayValidator<T>

Inherited from

BaseValidator.array

Defined in

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


nullable

get nullable(): UnionValidator<null | T>

Returns

UnionValidator<null | T>

Inherited from

BaseValidator.nullable

Defined in

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


nullish

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

Returns

UnionValidator<undefined | null | T>

Inherited from

BaseValidator.nullish

Defined in

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


optional

get optional(): UnionValidator<undefined | T>

Returns

UnionValidator<undefined | T>

Inherited from

BaseValidator.optional

Defined in

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


set

get set(): SetValidator<T>

Returns

SetValidator<T>

Inherited from

BaseValidator.set

Defined in

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

Methods

addConstraint

Protected addConstraint(constraint): NativeEnumValidator<T>

Parameters

NameType
constraintIConstraint<T[keyof T], T[keyof T]>

Returns

NativeEnumValidator<T>

Inherited from

BaseValidator.addConstraint

Defined in

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


clone

Protected clone(): NativeEnumValidator<T>

Returns

NativeEnumValidator<T>

Overrides

BaseValidator.clone

Defined in

projects/shapeshift/src/validators/NativeEnumValidator.ts:54


default

default(value): DefaultValidator<Exclude<T[keyof T], undefined>>

Parameters

NameType
valueExclude<T[keyof T], undefined> | () => Exclude<T[keyof T], undefined>

Returns

DefaultValidator<Exclude<T[keyof T], undefined>>

Inherited from

BaseValidator.default

Defined in

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


handle

Protected handle(value): Result<T[keyof T], ValidationError | UnknownEnumValueError>

Parameters

NameType
valueunknown

Returns

Result<T[keyof T], ValidationError | UnknownEnumValueError>

Overrides

BaseValidator.handle

Defined in

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


or

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

Type parameters

Name
O

Parameters

NameType
...predicatesreadonly BaseValidator<O>[]

Returns

UnionValidator<T[keyof T] | O>

Inherited from

BaseValidator.or

Defined in

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


parse

parse(value): T[keyof T]

Parameters

NameType
valueunknown

Returns

T[keyof T]

Inherited from

BaseValidator.parse

Defined in

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


run

run(value): Result<T[keyof T], BaseError>

Parameters

NameType
valueunknown

Returns

Result<T[keyof T], BaseError>

Inherited from

BaseValidator.run

Defined in

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


transform

transform(cb): NativeEnumValidator<T>

Parameters

NameType
cb(value: T[keyof T]) => T[keyof T]

Returns

NativeEnumValidator<T>

Inherited from

BaseValidator.transform

Defined in

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

transform<O>(cb): BaseValidator<O>

Type parameters

Name
O

Parameters

NameType
cb(value: T[keyof T]) => O

Returns

BaseValidator<O>

Inherited from

BaseValidator.transform

Defined in

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