typend

Index

Namespaces

Enumerations

Classes

Type aliases

Variables

Functions

Object literals

Type aliases

$PropsOf

Ƭ $PropsOf: object

Type declaration:

  • __eveble_payload: T

  • __eveble_validation: PROPERTIES_OF


$TypeOf

Ƭ $TypeOf: object

Type declaration:

  • __eveble_payload: T

  • __eveble_validation: TYPE_OF

Variables

Const DEFINABLE_KEY

DEFINABLE_KEY: keyof symbol = Symbol('eveble🎏definable')


Const INITIALIZER_KEY

INITIALIZER_KEY: keyof symbol = Symbol('eveble:initializer')


Const INJECTABLE_PROPERTIES_KEY

INJECTABLE_PROPERTIES_KEY: keyof symbol = Symbol( 'eveble:containers:injectable-definition' )


Const INTERFACE_NAME_KEY

INTERFACE_NAME_KEY: keyof symbol = Symbol( 'eveble:interface-name' )


Const INTERNAL_METHODS_KEY

INTERNAL_METHODS_KEY: keyof symbol = Symbol( 'eveble:containers:internal:methods' )


Const INTERNAL_PROPS_KEY

INTERNAL_PROPS_KEY: keyof symbol = Symbol( 'eveble:containers:internal:props' )


Const PATTERN_KEY

PATTERN_KEY: keyof symbol = Symbol('eveble:pattern-kind')


Const PROPERTIES_KEY

PROPERTIES_KEY: keyof symbol = Symbol( 'eveble:containers:definition' )


Const REFLECTION_KEY

REFLECTION_KEY: keyof symbol = Symbol( 'eveble:containers:reflection' )


Const VALIDATION_KEY

VALIDATION_KEY: keyof symbol = Symbol('eveble🎏validation')


Const VALIDATION_PAYLOAD_KEY

VALIDATION_PAYLOAD_KEY: "__eveble_payload" = "__eveble_payload"


Const VALIDATION_TYPE_KEY

VALIDATION_TYPE_KEY: "__eveble_validation" = "__eveble_validation"


Const VALIDATION_TYPE_PROPS_OF_KEY

VALIDATION_TYPE_PROPS_OF_KEY: "__eveble_validation_type_props_of" = "__eveble_validation_type_props_of"


Const any

any: Any‹› = new Any()


Const boolean

boolean: Function = Boolean


Const classTransformers

classTransformers: Map‹string, TypeTransformer› = new Map()


Const converter

converter: Converter = new TSRuntimeConverter()


Const describer

describer: Describer‹› = new Describer()


Const integer

integer: Integer = Integer


Const isInstanceOf

isInstanceOf: any = typend.isInstanceOf.bind(typend)


Const isValid

isValid: any = typend.isValid.bind(typend)


Const never

never: Never‹› = new Never()


Const number

number: Function = Number


Const string

string: Function = String


Const symbol

symbol: Function = Symbol


Const typend

typend: Library = new Typend(converter, describer, validator)


Const unknown

unknown: Unknown‹› = new Unknown()


Const validate

validate: any = typend.validate.bind(typend)


Const validator

validator: Validator = new Validator()


Const voided

voided: Void‹› = new Void()

Functions

collection

collection(properties: Record‹keyof any, any›): Collection

Parameters:

NameType
propertiesRecord‹keyof any, any›

Returns: Collection


collectionIncluding

collectionIncluding(properties: Record‹keyof any, any›): CollectionIncluding

Parameters:

NameType
propertiesRecord‹keyof any, any›

Returns: CollectionIncluding


collectionWithin

collectionWithin(properties: Record‹keyof any, any›): CollectionWithin

Parameters:

NameType
propertiesRecord‹keyof any, any›

Returns: CollectionWithin


eq

eq(expectation: any): Equals

Parameters:

NameType
expectationany

Returns: Equals


getMatchingParentProto

getMatchingParentProto(childProto: any, matcher: function): Prototype | undefined

Returns prototype from parent(s) that matches matcher(for use case with 'polytype' package)

Parameters:

childProto: any

Child class prototype.

matcher: function

Matcher function, that returns boolean on matching prototype.

▸ (proto: Prototype): boolean

Parameters:

NameType
protoPrototype

Returns: Prototype | undefined

Parent's matching prototype, else undefined.


getResolvablePath

getResolvablePath(path: string, properties: Record‹keyof any, any›): string

Returns resolvable path to nearest node from deeply-nested object.

example

const defWithPattern = {
foo: {
baz: {
properties: {
c: 'value',
},
},
},
getResolvablePath('foo.baz.properties', defWithPattern); // 'foo.baz'
const defWithMissingProps = {
foo: {
baz: {},
},
getResolvablePath('foo.baz.qux.quux', defWithMissingProps) // 'foo.baz'

Parameters:

NameTypeDescription
pathstringPath to resolve.
propertiesRecord‹keyof any, any›-

Returns: string

Determined nearest resolvable path as a string.


internal

internal(proto: Prototype, propertyKey: string): void

Annotates internal element of a class(like property that is not a part of 'exposed' type definition, or method handling routed message) that will be ignored durning validation or processing.

example

class MyClass {
name: string;
@internal engine: Engine
@internal
MyMessage(message: MyMessage): void {}
}

Parameters:

NameTypeDescription
protoPrototypePrototype.
propertyKeystringProperty or method name(key) as a string.

Returns: void


iof

iof(type: any): InstanceOf

Parameters:

NameType
typeany

Returns: InstanceOf


isDefined

isDefined(ctor: any): boolean

Evaluates if provided class constructor has @define decorator applied.

Parameters:

NameTypeDescription
ctoranyClass constructor.

Returns: boolean

Returns true if provided class is definable, else false.


isInstanceOfExpectation

isInstanceOfExpectation(arg: any): boolean

Evaluates if provided argument is a matching instanceOf expectation.

Parameters:

NameTypeDescription
arganyEvaluated argument.

Returns: boolean

Returns true if provided argument is a matching instanceOf expectation(is instance of pattern: Class, InstanceOf or Interface), else false.


isPattern

isPattern(arg: any): boolean

Evaluates if provided argument is a pattern instance.

Parameters:

NameTypeDescription
arganyEvaluated argument.

Returns: boolean

Returns true if provided argument is pattern instance, else false.


isPatternClass

isPatternClass(arg: any): boolean

Evaluates if provided argument is a pattern class.

Parameters:

NameTypeDescription
arganyEvaluated argument.

Returns: boolean

Returns true if provided argument is pattern constructor, else false.


isPlainRecord

isPlainRecord(arg: any): boolean

Evaluates if provided argument is a plain record(plain object or Collection).

Parameters:

NameTypeDescription
arganyEvaluated argument.

Returns: boolean

Returns true if argument is an record(literal object or Collection instance), else false.


isResolvablePath

isResolvablePath(key: string, properties: Record‹keyof any, any›): boolean

Evaluates if key is resolvable on expected properties. This covers scenarios where iterating through each level of expected nested properties yields undefined for resolved key for both - expected properties and provided validated value. This will happen when additional, nested property difference was found on validated value and is not covered by expected properties.

Parameters:

NameTypeDescription
keystringKey that needs to be resolved on evaluated value and the expectation as properties.
propertiesRecord‹keyof any, any›Expected properties for which resolvable key is evaluated.

Returns: boolean

Returns true if property expectation is resolvable by key, else false.


isSpecial

isSpecial(reflectedType: tsrTypes.ReflectedType): boolean

Evaluates whether reflected type is a special 'utility type'.

Parameters:

NameTypeDescription
reflectedTypetsrTypes.ReflectedTypeReflected type that will be converted.

Returns: boolean

Returns true if reflected type is special utility type, else false.


isUtility

isUtility(arg: any): boolean

Evaluates if provided argument is a utility instance.

Parameters:

NameTypeDescription
arganyEvaluated argument.

Returns: boolean

Returns true if provided argument is utility instance, else false.


isValidable

isValidable(ctor: any): boolean

Evaluates if provided class is validable.

Parameters:

NameTypeDescription
ctoranyClass constructor.

Returns: boolean

Returns true if provided class is validable, else false.


list

list(...expectations: any[]): List

Parameters:

NameType
...expectationsany[]

Returns: List


maybe

maybe(expectation: any): Maybe

Parameters:

NameType
expectationany

Returns: Maybe


oneOf

oneOf(...expectations: any[]): OneOf

Parameters:

NameType
...expectationsany[]

Returns: OneOf


optional

optional(expectation: any): Optional

Parameters:

NameType
expectationany

Returns: Optional


propsOf

propsOf(type: Class): PropsOf

Parameters:

NameType
typeClass

Returns: PropsOf


tuple

tuple(...expectations: any[]): Tuple

Parameters:

NameType
...expectationsany[]

Returns: Tuple


typeOf

typeOf(type: Class): TypeOf

Parameters:

NameType
typeClass

Returns: TypeOf


unrecognized

unrecognized(expectation?: any): Unrecognized

Parameters:

NameType
expectation?any

Returns: Unrecognized


validable

validable(isValidable?: boolean): ClassDecorator

Flags class as supporting(true) or disabling(false) validation.

Parameters:

NameTypeDescription
isValidable?booleanFlag indicating if class supports validation.

Returns: ClassDecorator

Class decorator function.


where

where(fn: Function): Where

Parameters:

NameType
fnFunction

Returns: Where

Object literals

Const PropTypes

PropTypes: object

any

any: Any‹›

array

array: ArrayConstructor = Array

arrayOf

arrayOf: list = list

bool

bool: BooleanConstructor = Boolean

equal

equal: eq = eq

func

func: FunctionConstructor = Function

instanceOf

instanceOf: iof = iof

integer

integer: Integer

maybe

maybe: maybe

never

never: Never‹›

number

number: NumberConstructor = Number

object

object: Collection‹› = new Collection({})

string

string: StringConstructor = String

symbol

symbol: SymbolConstructor = Symbol

tuple

tuple: tuple

void

void: Void‹› = voided

where

where: where

interface

interface(properties: Record‹keyof any, any›): Interface

Parameters:

NameType
propertiesRecord‹keyof any, any›

Returns: Interface

objectOf

objectOf(_props: any): Collection‹›

Parameters:

NameType
_propsany

Returns: Collection‹›

oneOf

oneOf(expectations: any[]): OneOf‹›

Parameters:

NameType
expectationsany[]

Returns: OneOf‹›

oneOfType

oneOfType(expectations: any[]): OneOf‹›

Parameters:

NameType
expectationsany[]

Returns: OneOf‹›

shape

shape(properties: Record‹keyof any, any›): Collection

Parameters:

NameType
propertiesRecord‹keyof any, any›

Returns: Collection