Skip to content

Latest commit

 

History

History
127 lines (75 loc) · 2.26 KB

itype.md

File metadata and controls

127 lines (75 loc) · 2.26 KB

mobx-state-tree > IType

Interface: IType

A type, either complex or simple.

Type parameters

C

S

T

Hierarchy

IType

ISimpleType

ISnapshotProcessor

IModelType

Index

Properties

Methods


Properties

name

● name: string

Friendly type name.


Methods

create

create(...args: CreateParams<C>): STNValue<T, this>

create(snapshot: C, env?: any): STNValue<T, this>

Parameters:

Name Type
Rest args CreateParams<C>

Returns: STNValue<T, this>

Creates an instance for the type given an snapshot input.

Parameters:

Name Type
snapshot C
Optional env any

Returns: STNValue<T, this> An instance of that type.


describe

describe(): string

Gets the textual representation of the type as a string.

Returns: string


is

is(thing: any): boolean

Checks if a given snapshot / instance is of the given type.

Parameters:

Name Type Description
thing any Snapshot or instance to be checked.

Returns: boolean true if the value is of the current type, false otherwise.


validate

validate(thing: C, context: IValidationContext): IValidationResult

Run's the type's typechecker on the given value with the given validation context.

Parameters:

Name Type Description
thing C Value to be checked, either a snapshot or an instance.
context IValidationContext Validation context, an array of { subpaths, subtypes } that should be validated

Returns: IValidationResult The validation result, an array with the list of validation errors.