ClassValidator

Hierarchy

Implements

Index

Properties

Methods

Properties

Static describer

describer: Describer

Inherited from PatternValidator.describer

Overrides void

Methods

canValidate

canValidate(expectation: Expectation): boolean

Evaluates if validator can handle provided expectation.

Parameters:

NameTypeDescription
expectationExpectationEvaluated explicit Pattern instance or implicit expectation.

Returns: boolean

Returns true if pattern is instance of Class pattern, else false.


describe

describe(value: any): string

Inherited from PatternValidator.describe

Overrides void

Parameters:

NameType
valueany

Returns: string


validate

validate(value: any, pattern: Class, validator: Validator): boolean

Implementation of PatternValidator

Validates value against Class with the given type and properties. Properties must not contain any keys not listed in the pattern. Properties argument must be an instance of plain Object with no special prototype or instance of Collection.

throws {InvalidTypeError} Thrown if the value is not an class instance.

throws {UnexpectedKeyError} Thrown if the value has unexpected key.

throws {ValidationError} Thrown if the value does not match expectation.

Parameters:

NameTypeDescription
valueanyValue that is validated against expectation.
patternClassExplicit pattern as Class instance.
validatorValidatorValidator matching Validator interface.

Returns: boolean

Returns true if value is matching exactly Class pattern expectation.


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