ISimpleType
mobx-state-tree - v7.0.0 › ISimpleType
A simple type, this is, a type where the instance and the snapshot representation are the same.
Type parameters
▪ T
Hierarchy
IType‹T, T, T›
↳ ISimpleType
Index
Properties
Methods
Properties
Optional
identifierAttribute
• identifierAttribute? : undefined | string
Inherited from IType.identifierAttribute
Defined in src/core/type/type.ts:92
Name of the identifier attribute or null if none.
name
• name: string
Defined in src/core/type/type.ts:87
Friendly type name.
Methods
create
▸ create(snapshot?
: T | ExcludeReadonly‹T›, env?
: any): this["Type"]
Defined in src/core/type/type.ts:99
Creates an instance for the type given an snapshot input.
Parameters:
Name | Type |
---|---|
snapshot? | T | ExcludeReadonly‹T› |
env? | any |
Returns: this["Type"]
An instance of that type.
describe
▸ describe(): string
Defined in src/core/type/type.ts:121
Gets the textual representation of the type as a string.
Returns: string
is
▸ is(thing
: any): thing is T | this["Type"]
Defined in src/core/type/type.ts:107
Checks if a given snapshot / instance is of the given type.
Parameters:
Name | Type | Description |
---|---|---|
thing | any | Snapshot or instance to be checked. |
Returns: thing is T | this["Type"]
true if the value is of the current type, false otherwise.
validate
▸ validate(thing
: T | T, context
: IValidationContext): IValidationResult
Defined in src/core/type/type.ts:116
Run's the type's typechecker on the given value with the given validation context.
Parameters:
Name | Type | Description |
---|---|---|
thing | T | T | 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.