typend
Index
Namespaces
Enumerations
Classes
- Any
- AnyValidator
- ArrayConverter
- ArrayDescriber
- Class
- ClassConverter
- ClassDescriber
- ClassValidator
- Collection
- CollectionIncluding
- CollectionIncludingValidator
- CollectionValidator
- CollectionWithin
- CollectionWithinValidator
- CompactDescriber
- DebugDescriber
- Describer
- Description
- DescriptionList
- DescriptionListDescriber
- Equals
- EqualsValidator
- ErrorDescriber
- FallbackDescriber
- FunctionConverter
- InjectingPropsTransformer
- InstanceOf
- InstanceOfValidator
- Integer
- IntegerValidator
- Interface
- InterfaceValidator
- Internal
- InternalPropsTransformer
- InternalValidator
- InvalidDefinitionError
- InvalidTypeError
- InvalidValueError
- List
- ListValidator
- LiteralConverter
- LocaleString
- LocaleStringValidator
- Maybe
- MaybeValidator
- MyClass
- MyError
- MyOtherClass
- MyOtherError
- NativeConverter
- NativeTypeDescriber
- Never
- NeverValidator
- NilConverter
- NotAMemberError
- ObjectConverter
- ObjectDescriber
- OneOf
- OneOfValidator
- Optional
- OptionalValidator
- Pattern
- PatternValidator
- PatternValidatorExistError
- PatternValidatorNotFoundError
- PrimitiveConverter
- PropsOf
- PropsOfConverter
- ReferenceConverter
- TSRuntimeConverter
- Tuple
- TupleConverter
- TupleValidator
- TypeConverterExists
- TypeDescriberExistsError
- TypeDescriberNotFoundError
- TypeOf
- TypeOfConverter
- Typend
- UndefinableClassError
- UnequalValueError
- UnexpectedKeyError
- UnionConverter
- Unknown
- UnknownConverter
- UnknownError
- UnknownValidator
- UnmatchedTypeError
- Unrecognized
- UnrecognizedConverter
- UnrecognizedValidator
- Utility
- ValidationError
- Validator
- Void
- VoidValidator
- Where
- WhereValidator
- WrapperPattern
Type aliases
Variables
- DEFINABLE_KEY
- INITIALIZER_KEY
- INJECTABLE_PROPERTIES_KEY
- INTERFACE_NAME_KEY
- INTERNAL_METHODS_KEY
- INTERNAL_PROPS_KEY
- PATTERN_KEY
- PROPERTIES_KEY
- REFLECTION_KEY
- VALIDATION_KEY
- VALIDATION_PAYLOAD_KEY
- VALIDATION_TYPE_KEY
- VALIDATION_TYPE_PROPS_OF_KEY
- any
- boolean
- classTransformers
- converter
- describer
- integer
- isInstanceOf
- isValid
- never
- number
- string
- symbol
- typend
- unknown
- validate
- validator
- voided
Functions
- collection
- collectionIncluding
- collectionWithin
- eq
- getMatchingParentProto
- getResolvablePath
- internal
- iof
- isDefined
- isInstanceOfExpectation
- isPattern
- isPatternClass
- isPlainRecord
- isResolvablePath
- isSpecial
- isUtility
- isValidable
- list
- maybe
- oneOf
- optional
- propsOf
- tuple
- typeOf
- unrecognized
- validable
- where
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:
| Name | Type |
|---|---|
properties | Record‹keyof any, any› |
Returns: Collection
collectionIncluding
▸ collectionIncluding(properties: Record‹keyof any, any›): CollectionIncluding
Parameters:
| Name | Type |
|---|---|
properties | Record‹keyof any, any› |
Returns: CollectionIncluding
collectionWithin
▸ collectionWithin(properties: Record‹keyof any, any›): CollectionWithin
Parameters:
| Name | Type |
|---|---|
properties | Record‹keyof any, any› |
Returns: CollectionWithin
eq
▸ eq(expectation: any): Equals
Parameters:
| Name | Type |
|---|---|
expectation | any |
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:
| Name | Type |
|---|---|
proto | Prototype |
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
Parameters:
| Name | Type | Description |
|---|---|---|
path | string | Path to resolve. |
properties | Record‹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
Parameters:
| Name | Type | Description |
|---|---|---|
proto | Prototype | Prototype. |
propertyKey | string | Property or method name(key) as a string. |
Returns: void
iof
▸ iof(type: any): InstanceOf
Parameters:
| Name | Type |
|---|---|
type | any |
Returns: InstanceOf
isDefined
▸ isDefined(ctor: any): boolean
Evaluates if provided class constructor has @define decorator applied.
Parameters:
| Name | Type | Description |
|---|---|---|
ctor | any | Class 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:
| Name | Type | Description |
|---|---|---|
arg | any | Evaluated 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:
| Name | Type | Description |
|---|---|---|
arg | any | Evaluated 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:
| Name | Type | Description |
|---|---|---|
arg | any | Evaluated 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:
| Name | Type | Description |
|---|---|---|
arg | any | Evaluated 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:
| Name | Type | Description |
|---|---|---|
key | string | Key that needs to be resolved on evaluated value and the expectation as properties. |
properties | Record‹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:
| Name | Type | Description |
|---|---|---|
reflectedType | tsrTypes.ReflectedType | Reflected 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:
| Name | Type | Description |
|---|---|---|
arg | any | Evaluated 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:
| Name | Type | Description |
|---|---|---|
ctor | any | Class constructor. |
Returns: boolean
Returns true if provided class is validable, else false.
list
▸ list(...expectations: any[]): List
Parameters:
| Name | Type |
|---|---|
...expectations | any[] |
Returns: List
maybe
▸ maybe(expectation: any): Maybe
Parameters:
| Name | Type |
|---|---|
expectation | any |
Returns: Maybe
oneOf
▸ oneOf(...expectations: any[]): OneOf
Parameters:
| Name | Type |
|---|---|
...expectations | any[] |
Returns: OneOf
optional
▸ optional(expectation: any): Optional
Parameters:
| Name | Type |
|---|---|
expectation | any |
Returns: Optional
propsOf
▸ propsOf(type: Class): PropsOf
Parameters:
| Name | Type |
|---|---|
type | Class |
Returns: PropsOf
tuple
▸ tuple(...expectations: any[]): Tuple
Parameters:
| Name | Type |
|---|---|
...expectations | any[] |
Returns: Tuple
typeOf
Parameters:
| Name | Type |
|---|---|
type | Class |
Returns: TypeOf
unrecognized
▸ unrecognized(expectation?: any): Unrecognized
Parameters:
| Name | Type |
|---|---|
expectation? | any |
Returns: Unrecognized
validable
▸ validable(isValidable?: boolean): ClassDecorator
Flags class as supporting(true) or disabling(false) validation.
Parameters:
| Name | Type | Description |
|---|---|---|
isValidable? | boolean | Flag indicating if class supports validation. |
Returns: ClassDecorator
Class decorator function.
where
▸ where(fn: Function): Where
Parameters:
| Name | Type |
|---|---|
fn | Function |
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:
| Name | Type |
|---|---|
properties | Record‹keyof any, any› |
Returns: Interface
objectOf
▸ objectOf(_props: any): Collection‹›
Parameters:
| Name | Type |
|---|---|
_props | any |
Returns: Collection‹›
oneOf
▸ oneOf(expectations: any[]): OneOf‹›
Parameters:
| Name | Type |
|---|---|
expectations | any[] |
Returns: OneOf‹›
oneOfType
▸ oneOfType(expectations: any[]): OneOf‹›
Parameters:
| Name | Type |
|---|---|
expectations | any[] |
Returns: OneOf‹›
shape
▸ shape(properties: Record‹keyof any, any›): Collection
Parameters:
| Name | Type |
|---|---|
properties | Record‹keyof any, any› |
Returns: Collection