Skip to content
Wyatt Greenway edited this page Aug 31, 2022 · 24 revisions

class Type

Base type class for all other field types.

static property Type::_isMythixFieldType

.


static property Type::clone

.


method Type::castToType(context: object)

Cast a value to the underlying field type.

This method is implemented differently for every field type. Its job is to cast any value provided to the type. For many types, if a null or undefined value is provided, then that value will simply be returned.

The "context" argument passed to this method has the following shape:

interface CastToTypeContext {
  connection: Connection;  // The connection of the model.
  Model: class Model;      // The parent Model class of the field.
  self: Model;             // The model instance.
  field: Field;            // The field descriptor that has this type.
  value: any;              // The value that should be cast.
};

Arguments:

  • context: object

    The "context" passed to castToType. This contains all that any type should need to cast a value.

Return value: any



Clone this wiki locally