[Go to site: main page, start]

Class TypedObjectField

A subclass of ObjectField that represents a mapping of keys to the provided DataField type.

Hierarchy (View Summary)

Index

Constructors

Properties

element: DataField

The value type of each entry in this object.

name: string | undefined

The field name of this DataField instance. This is assigned by SchemaField#initialize.

The initially provided options which configure the data field

parent: any

A reference to the parent schema to which this DataField belongs. This is assigned by SchemaField#initialize.

persisted: boolean = true

Is a value of this field written to source data? A Non-persisted value is initialized (with its initial value), and ActiveEffects can use the field for change application.

hierarchical: boolean = false

Whether this field defines part of a Document/Embedded Document hierarchy.

recursive: boolean = true

Accessors

  • get fieldPath(): string

    A dot-separated string representation of the field path within the parent schema.

    Returns string

  • get _defaults(): object

    Default parameters for this field type

    Returns object

  • get hasFormSupport(): boolean

    Does this form field class have defined form support?

    Returns boolean

Methods

  • Parameters

    • value: any
    • delta: any
    • model: any
    • change: any

    Returns any

  • Parameters

    • value: any

    Returns any

  • Parameters

    • data: any
    • options: any
    • _state: any

    Returns any

  • Parameters

    • source: any
    • key: any
    • value: any
    • diff: any
    • options: any

    Returns void

  • Parameters

    • key: any
    • value: any
    • options: any
    • state: any

    Returns void

  • Parameters

    • changes: any
    • options: {} = {}

    Returns void

  • Parameters

    • value: any
    • _options: any

    Returns void

  • Parameters

    • fn: any
    • data: {} = {}
    • options: {} = {}

    Returns {}

  • Apply an ActiveEffectChange to this field.

    Type Parameters

    • T

    Parameters

    • value: T

      The field's current value.

    • model: DataModel

      The model instance.

    • change: ActiveEffectChangeData

      The change to apply.

    • options: { replacementData?: Record<string, unknown> } = {}

      Additional options to configure the change application.

      • OptionalreplacementData?: Record<string, unknown>

        Data used to resolve "@" expressions.

    Returns T

    The updated value.

  • Preprocess and clean source data to ensure that it conforms to the correct data type for this field and is ready to be used by data model construction or update operations. Data cleaning is synchronous and automatically applied as the first step of construction and update operations.

    Parameters

    Returns any

    The cleaned value

  • Parameters

    • value: any
    • model: any
    • options: {} = {}

    Returns any

  • Render this DataField as a standardized form-group element.

    Parameters

    • groupConfig: FormGroupConfig = {}

      Configuration options passed to the wrapping form-group

    • inputConfig: FormInputConfig = {}

      Input element configuration options passed to DataField#toInput

    Returns HTMLDivElement

    The rendered form group element

  • Render this DataField as an HTML element.

    Parameters

    Returns HTMLElement | HTMLCollection | HTMLElement[]

    A rendered HTMLElement for the field

    An Error if this DataField subclass does not support input rendering

  • Validate candidate input for this field, ensuring it meets the field requirements.

    This public method validates recursively, testing both the immediate value of this field as well as the validity of any child values for fields with hierarchical data types.

    Parameters

    • value: any

      The candidate value to validate

    • Optionaloptions: DataFieldValidationOptions = {}

      Options which affect validation behavior

    Returns void | DataModelValidationFailure

    A failure that occurred if validation is non-strict. The failure may have been resolved by fallback or dropping invalid elements.

    A failure error type including details of the failure if validation is performed strictly.

  • Iterate over validation functions applied to this field. Validation happens in a depth-first way, for example consider an outerSchema with an innerField:

    Parameters

    Returns Generator<DataFieldValidator, void, unknown>

    outerSchema
    _validateSpecial
    _validateType
    _validateRecursive
    outerSchema.options.validate
    innerField
    _validateSpecial
    _validateType
    innerField.options.validate
    _validateModel
    _validateModel
  • Protected

    Apply a custom change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Apply a "downgrade" change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Apply a "multiply" change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Apply an "override" change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Apply a "subtract" change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Apply an "upgrade" change to this field.

    Parameters

    • value: any

      The field's current value.

    • delta: any

      The change delta.

    • model: DataModel

      The model instance.

    • change: EffectChangeData

      The original change data.

    Returns any

    The updated value.

  • Protected

    Cast a change delta into an appropriate type to be applied to this field.

    Parameters

    • delta: any

      The change delta.

    • replacementData: object = {}

      Data used to resolve "@" expressions.

    Returns any

  • Protected

    Recursively replace data references in a string change value.

    Parameters

    • raw: string
    • data: Record<string, unknown>

      An object providing replacements

    • Optionaloptions: { strict?: boolean } = {}

      Additional options to configure the data replacement

      • Optionalstrict?: boolean

        Throw an Error if data replacement fails

    Returns string

    The expression with data references resolved

  • Protected

    Render this DataField as an HTML element. Subclasses should implement this method rather than the public toInput method which wraps it.

    Parameters

    Returns HTMLElement | HTMLCollection | HTMLElement[]

    A rendered HTMLElement for the field

    An Error if this DataField subclass does not support input rendering

  • Protected

    Special validation rules which supersede regular field validation. This validator screens for certain values which are otherwise incompatible with this field like null or undefined.

    Parameters

    • value: any

      The candidate value

    Returns boolean | void

    A boolean to indicate with certainty whether the value is valid

    An error with a specific reason the value is invalid