functional-models
    Preparing search index...

    Interface ModelReferencePropertyInstance<TData, TProperty, TModelExtensions, TModelInstanceExtensions>

    An extends a Property to add additional functions helpful for dealing with referenced models.

    interface ModelReferencePropertyInstance<
        TData extends DataDescription,
        TProperty extends Arrayable<DataValue>,
        TModelExtensions extends object = object,
        TModelInstanceExtensions extends object = object,
    > {
        createGetter: (
            value: TProperty,
            modelData: Readonly,
            modelInstance: ModelInstance<
                Readonly<{ [s: string]: any }>,
                object,
                object,
            >,
        ) => ValueGetter<TProperty, Readonly<{ [s: string]: any }>, object, object>;
        getChoices: () => readonly ChoiceTypes[];
        getConfig: () => object;
        getConstantValue: () => undefined | TProperty;
        getDefaultValue: () => undefined | TProperty;
        getPropertyType: () => string;
        getReferencedId: (
            instanceValues: ModelReferenceType<
                TData,
                TModelExtensions,
                TModelInstanceExtensions,
            >,
        ) => Maybe<PrimaryKeyType>;
        getReferencedModel: () => ModelType<
            TData,
            TModelExtensions,
            TModelInstanceExtensions,
        >;
        getValidator: (
            valueGetter: ValueGetter<
                TProperty,
                Readonly<{ [s: string]: any }>,
                object,
                object,
            >,
        ) => PropertyValidator<Readonly<{ [s: string]: any }>>;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    createGetter: (
        value: TProperty,
        modelData: Readonly,
        modelInstance: ModelInstance<
            Readonly<{ [s: string]: any }>,
            object,
            object,
        >,
    ) => ValueGetter<TProperty, Readonly<{ [s: string]: any }>, object, object>

    Creates a value getter.

    Type declaration

      • (
            value: TProperty,
            modelData: Readonly,
            modelInstance: ModelInstance<
                Readonly<{ [s: string]: any }>,
                object,
                object,
            >,
        ): ValueGetter<TProperty, Readonly<{ [s: string]: any }>, object, object>
      • Parameters

        • value: TProperty

          The type of value

        • modelData: Readonly

          The type of data.

        • modelInstance: ModelInstance<Readonly<{ [s: string]: any }>, object, object>

          An instance of the model that has the data.

        Returns ValueGetter<TProperty, Readonly<{ [s: string]: any }>, object, object>

    getChoices: () => readonly ChoiceTypes[]

    Gets available choices for limiting the value of this property.

    getConfig: () => object

    Gets the configuration passed into the property constructor.

    getConstantValue: () => undefined | TProperty

    If there is a constant value that never changes. (This is used above all else).

    getDefaultValue: () => undefined | TProperty

    If there is a default value

    getPropertyType: () => string

    Gets the ValueType of the property. Unless custom properties are used, the value is a PropertyType. Otherwise the value could be string for custom types.

    getReferencedId: (
        instanceValues: ModelReferenceType<
            TData,
            TModelExtensions,
            TModelInstanceExtensions,
        >,
    ) => Maybe<PrimaryKeyType>

    Gets the id (foreign key) of the referenced model.

    Type declaration

    getReferencedModel: () => ModelType<
        TData,
        TModelExtensions,
        TModelInstanceExtensions,
    >

    Gets reference's model

    getValidator: (
        valueGetter: ValueGetter<
            TProperty,
            Readonly<{ [s: string]: any }>,
            object,
            object,
        >,
    ) => PropertyValidator<Readonly<{ [s: string]: any }>>

    Gets a validator for the property. This is not normally used. Instead for validation look at ModelInstance.validate

    Type declaration

      • (
            valueGetter: ValueGetter<
                TProperty,
                Readonly<{ [s: string]: any }>,
                object,
                object,
            >,
        ): PropertyValidator<Readonly<{ [s: string]: any }>>
      • Parameters

        • valueGetter: ValueGetter<TProperty, Readonly<{ [s: string]: any }>, object, object>

          The getter for the value.

        Returns PropertyValidator<Readonly<{ [s: string]: any }>>