DefinableMixin
Hierarchy
- DefinableMixin
Implements
- Definable
- Definable
Index
Methods
- equals
- getPropTypes
- getPropertyInitializers
- toPlainObject
- validateProps
- getPropTypes
- getPropertyInitializers
Methods
equals
▸ equals(other
: any): boolean
Implementation of Definable
Evaluates if value and value's type of passed other instance are equal to current one.
example
example
example
Parameters:
Name | Type | Description |
---|---|---|
other | any | Other instance of DefinableMixin. |
Returns: boolean
Returns true
if other instance of DefinableMixin is equal, else false
.
getPropTypes
▸ getPropTypes(): Props
Implementation of Definable
Returns class properties types from whole inheritance tree.
example
Returns: Props
Plain object representation of properties types.
getPropertyInitializers
▸ getPropertyInitializers(): Props
Implementation of Definable
Returns default values metadata from property initializers conversion for whole inheritance tree.
example
Returns: Props
Default values for properties.
toPlainObject
▸ toPlainObject(): Props
Implementation of Definable
Converts properties to plain object.
remarks
Loosing object references is required since in scenarios when properties resolved
from toPlainObject
are transformed - in such changes to the modified plain object
will cascade to original instance(THIS instance, since properties are referenced).
example
Returns: Props
Public properties with assigned values as plain object.
validateProps
▸ validateProps(props
: Record‹string | number | symbol, any› | undefined, propTypes
: PropTypes, isStrict?
: boolean): boolean
Validates if provided properties matches prop types.
throws
{ValidationError}
Thrown if the passed properties do not match prop types.
remarks
Disabling of runtime validation is possible via Kernel's configuration(and by
that env flags also) or by annotating class with @validable(false)
.
This is useful when there is external layer(like transportation) that does all the heavy lifting of validation and there are no other sources of incoming data beside points that is handled by layer.
Use env EVEBLE_VALIDATION_TYPE
set to manual
to disable validation on
initialization. You ca re-enable it again on your application configuration via
path validation.type
set to runtime
before staring application.
example
Parameters:
Name | Type | Description |
---|---|---|
props | Record‹string | number | symbol, any› | undefined | Properties to validate. |
propTypes | PropTypes | Properties types. |
isStrict? | boolean | Flag indicating that validation should be done in strict mode. |
Returns: boolean
Returns true
if properties are valid, else throws.
Static
getPropTypes
▸ getPropTypes(): Props
Returns class properties types from whole inheritance tree.
example
Returns: Props
Plain object representation of properties types.
Static
getPropertyInitializers
▸ getPropertyInitializers(): Props
Returns class property initializers for whole inheritance tree.
example
Returns: Props
Plain object representation of property initializers.