Skip to content
Wyatt Greenway edited this page Sep 1, 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: CastToTypeContext)

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.

Interface:

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

Arguments:

  • context: CastToTypeContext

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

Return value: any



Clone this wiki locally