Typend

Hierarchy

  • Typend

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new Typend(converter: Converter, describer: Describer, validator: Validator): Typend

Creates an instance of Typend. Creates an instance of Typend.

Parameters:

NameTypeDescription
converterConverterConversion library matching Converter interface.
describerDescriberDescription library matching Describer interface.
validatorValidatorValidation library matching Validator interface.

Returns: Typend

Properties

converter

converter: Converter

Implementation of Library.converter


describer

describer: Describer

Implementation of Library.describer


validator

validator: Validator

Implementation of Library.validator

Methods

debug

debug(isDebugging?: boolean): void

Implementation of Library

Setup debugging mode on Typend.

Parameters:

NameTypeDescription
isDebugging?booleanBoolean flags indicating that debugging should be enabled.

Returns: void


getConverter

getConverter(): Converter

Implementation of Library

Returns converting library.

Returns: Converter

Converter library instance.


getDescriber

getDescriber(): Describer

Implementation of Library

Returns describing library.

Returns: Describer

Describer library instance.


getValidator

getValidator(): Validator

Implementation of Library

Returns validator library.

Returns: Validator

Validator library instance.


isInstanceOf

isInstanceOf(value: any, expectation: any): boolean

Validates if a value is instance of expectation.

Parameters:

NameTypeDescription
valueanyValue that needs to validated.
expectationanyExpectation as explicit Class, InstanceOf, Interface pattern instance against which value will be validated.

Returns: boolean

Returns true if validation is successful, else false.


isValid

isValid(value: any, expectation: Expectation | Utility, isStrict?: boolean): boolean

Implementation of Library

Validates if a value matches an expectation.

Parameters:

NameTypeDescription
valueanyValue that needs to validated.
expectationExpectation | UtilityExpectation as explicit Pattern instance, instance of Utility or implicit expectation against which value will be validated.
isStrict?booleanFlag indicating that evaluation should be done in strict mode.

Returns: boolean

Returns true if validation is successful, else false.


setConverter

setConverter(converter: Converter): void

Implementation of Library

Sets converting library.

Parameters:

NameTypeDescription
converterConverterDescription library matching Describer interface.

Returns: void


setDescriber

setDescriber(describer: Describer): void

Implementation of Library

Sets describing library.

Parameters:

NameTypeDescription
describerDescriberConversion library matching Converter interface.

Returns: void


setValidator

setValidator(validator: Validator): void

Implementation of Library

Sets validator library.

Parameters:

NameTypeDescription
validatorValidatorValidation library matching Validator interface.

Returns: void


validate

validate(value: any, expectation: Expectation | Utility, isStrict?: boolean): boolean

Implementation of Library

Validates if a value matches an expectation or throws.

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

Parameters:

NameTypeDescription
valueanyValue that needs to validated.
expectationExpectation | UtilityExpectation as explicit Pattern instance, instance of Utility or implicit expectation against which value will be validated.
isStrict?booleanFlag indicating that evaluation should be done in strict mode.

Returns: boolean

Returns true if validation is successful, else throws.