InstanceOfValidator

Hierarchy

Implements

Index

Properties

Methods

Object literals

Properties

Static describer

describer: Describer

Inherited from PatternValidator.describer

Overrides void

Methods

canValidate

canValidate(expectation: Expectation): boolean

Evaluates if validator can handle provided explicit pattern or implicit expectation.

Parameters:

NameTypeDescription
expectationExpectationEvaluated explicit Pattern instance or implicit expectation.

Returns: boolean

Returns true if pattern is instance of InstanceOf or is a native type class, nil, class constructor, error constructor, else false.


describe

describe(value: any): string

Inherited from PatternValidator.describe

Overrides void

Parameters:

NameType
valueany

Returns: string


validate

validate(value: any, instanceOfOrExpect: Expectation): boolean

Validates if value is instance of an expectation type.

throws {InvalidTypeError} Thrown if the value is an array(use ArrayPattern for array values).

throws {UnmatchedTypeError} Thrown if the value is not same type as expectation require.

Parameters:

NameTypeDescription
valueanyValue that is validated against expectation.
instanceOfOrExpectExpectationExplicit pattern as InstanceOf instance or a native type class, nil, class constructor, error constructor against which value is validated.

Returns: boolean

Returns true if value has same type as expectation, else throws.


Static getDescriber

getDescriber(): Describer

Inherited from PatternValidator.getDescriber

Overrides void

Returns: Describer


Static setDescriber

setDescriber(describer: Describer): void

Inherited from PatternValidator.setDescriber

Overrides void

Parameters:

NameType
describerDescriber

Returns: void

Object literals

Static MAPPINGS

MAPPINGS: object

symbol

symbol: SymbolConstructor = Symbol