Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A subclass of DataField which deals with object-typed data.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    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 = false

    Does this field type contain other fields in a recursive structure? Examples of recursive fields are SchemaField, ArrayField, or TypeDataField Examples of non-recursive fields are StringField, NumberField, or ObjectField

    Accessors

    • get fieldPath(): string

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

      Returns string

    • get _defaults(): DataFieldOptions & { nullable: boolean; required: boolean }

      Default parameters for this field type

      Returns DataFieldOptions & { nullable: boolean; required: boolean }

    • 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

    • Internal

      Commit a prepared update to DataModel#_source.

      Parameters

      • source: any

        The parent source object within which the key field exists

      • key: any

        The named field in source to commit

      • value: any

        The new value of the field which should be committed to source

      • diff: any

        The reported change to the field

      • options: any

        Options which modify how this update workflow is performed.

      Returns void

    • Parameters

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

      Returns void

    • Internal

      Certain fields may declare joint data validation criteria. This method will only be called if the field is designated as recursive. This method should throw if any validation error occurred, even if resolved by fallback or dropping.

      Parameters

      • data: object

        Candidate data for joint model validation

      • options: object = {}

        Options which modify joint model validation

      Returns void

      An error if joint model validation fails

    • Parameters

      • value: any
      • _options: any

      Returns void

    • Apply a function to this DataField which propagates through recursively to any contained data schema.

      Parameters

      • fn: string | Function

        The function to apply

      • value: any

        The current value of this field

      • Optionaloptions: object = {}

        Additional options passed to the applied function

      Returns object

      The results object

    • Apply an ActiveEffectChange to this field.

      Type Parameters

      • T

      Parameters

      • value: T

        The field's current value.

      • model: DataModel

        The model instance.

      • change: EffectChangeData

        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 traverse a schema and retrieve a field specification by a given path/key

      Parameters

      • parts: string[]

        The field path or property key if source is passed as an array of strings (in reverse order)

      • Optionaloptions: { source?: object; type?: object } = {}

        Additional options

        • Optionalsource?: object

          The source data of the field

        • Optionaltype?: object

          The Document type of the parent field

      Returns DataField | undefined

      The corresponding DataField definition for that field, or undefined

    • 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

      For fields which have hierarchical data structures, define how their inner fields should be validated. This method is called after _validateSpecial and _validateType. It can be assumed that those tests passed. This method should throw if any validation error occurred, even if resolved by fallback or dropping.

      Parameters

      Returns boolean | void

      A boolean to indicate with certainty whether the value is valid

      An error with a specific reason the value is invalid

    • 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