Just the data that is used to describe this input value. It should not contain any supporting functions or services. It should be generatable from JSON, and simply gets typed to InputValueHostConfig. This provides the backing data for each InputValueHost. The server side could in fact supply this object via JSON, allowing the server's Model to dictate this, except values are converted to their native forms like a JSON date is a Date object. However, there are sometimes cases a business rule is client side only (parser error converting "abc" to number) and times when a business rule is server side only (looking for injection attacks for the purpose of logging and blocking.)

interface InputValueHostConfig {
    parserLookupKey?: null | string;
    parserCreator?: ((valueHost) => null | IDataTypeParser<any>);
    group?: null | string | string[];
    validatorConfigs: null | ValidatorConfig[];
    valueHostType?: string;
    name: string;
    label?: string;
    labell10n?: null | string;
    initialValue?: any;
    dataType?: string;
    initialEnabled?: boolean;
    enablerConfig?: ConditionConfig;
}

Hierarchy (view full)

Properties

parserLookupKey?: null | string

A DataTypeParser object is used when calling setInputValue() to convert the input value into the native value. It results in calling setValue() with the native value, or if the parser had an error, calling setValueToUndefined() and retaining the error information to show in the error message.

The value here is a lookup key, and is usually one of the Data Type lookup keys, like LookupKey.Integer for an integer-specific parser. However, individual DataTypeParser classes may have a unique lookup key to assign here.

  • Assign to the lookup key to use a parser that supports the lookup key.
  • Leave it undefined to use the dataType configuration property (for a Data Type Lookup Key) on the ValueHost, but remember to assign that property.
  • Assign to null to prevent any parser from being setup.

Note that the options object for setInputValue has a property called disableParser which if set to true will prevent parsing too.

Alternatively, you can leave this undefined and use parserCreator to create the DataTypeParser instance you want.

parserCreator?: ((valueHost) => null | IDataTypeParser<any>)

Alternative to parserLookupKey that establishes a parser used when calling setInputValue() to convert the input value into the native value. It results in calling setValue() with the native value, or if the parser had an error, calling setValueToUndefined() and retaining the error information to show in the error message.

It provides a callback function that is expected to create an object that implements IDataTypeParser or return null if no parser is appropriate.

While parserLookupKey knows how to fallback to another data type using LookupKeyFallbackService, this parser function completely ignores DataTypeParserService.parse where that happens. Instead, its up to you to handle any fallbacks. You should also expect that the parse() functions lookupKey parameter may be null if parserLookupKey and dataType properties were not setup.

Your parser object's supports() method will be called. If it returns false, your object won't be used, and it will fallback to the parserLookupKey.

Type declaration

Returns

Object that implements IDataTypeParser or return null if no parser is appropriate

group?: null | string | string[]

Validatable ValueHosts can be part of one or more named groups. Groups are part of validating the complete Model. All Validatable ValueHosts on the page may be asked to validate. Often fields are used for different aspects of the page, like a login or search field in the header is a different feature from the form where data is being gathered. Submit buttons usually call validate() and supply their group name. When they do, Validatable ValueHosts associated with that button must have the same group name. Values:

  • undefined, null or '*' all mean the group feature is ignored.
  • string - a single group name. If it does not match the requested group in the validate() function, the validator is treated as disabled. Case insensitive matching.
  • string[] - a list of group names. If none match the requested group in the validate() function, the validator is treated as disabled.
validatorConfigs: null | ValidatorConfig[]

How to validate based on the business rules. These are used to create actual validator objects. This array may need to host validators that are client-side only, such as parser error converting "abc" to number.

valueHostType?: string

Identifies the type of ValueHost that will be created to support the Config. Can use the enumeration ValueHostType to get these strings. InputValueHost - 'Input' PropertyValueHost - 'Property' StaticValueHost - 'Static' CalcValueHost - 'Calc' If left null, the ValueHostFactory will determine between StaticValueHost and InputValueHost by checking for inclusion of the InputValueHostConfig.validationConfigs property.

name: string

Provides a unique name for this ValueHost, within the scope of one ValueHostsManager instance. Consuming systems use this name to locate the ValueHost for which they will access a Value. Its up to the consuming system to define unique names. A good form is path notation through the module's properties, such as: AddressInfo/StreetName When a property is part of a collection/list, consider:

  • index into the list, a simple number starting at 0. Property1/0, Property1/1
  • Primary key when the children are data elements themselves. Property1/Key=abc123
label?: string

The UI-ready label for this value, to be shown in error messages that have the {Label} token.

labell10n?: null | string

Localization key for Label. Its value will be matched to an entry made to ValidationServices.TextLocalizerService, specific to the active culture. If setup and no entry was found in TextLocalizerService, the value from the errorMessage property is used.

initialValue?: any

Provides an initial value when constructing the instance. Changes to the value should come from setValue(), as they report state changes. Can be undefined/omitted. Note that a value of null or empty string are both considered real values to store. Only undefined means nothing to store.

dataType?: string

A name of a data type used to lookup supporting services specific to the data type. See LookupKey. Some examples: "String", "Number", "Date", "DateTime", "MonthYear". If null, the current value's type (ValueHostInstanceState.Value) is used and must be string, number, boolean, or date.

initialEnabled?: boolean

When defined, it is the initial value for isEnabled(). Its value overridden by calling setEnabled() or using an Enabler condition. It is not used when enablerConfig is defined.

enablerConfig?: ConditionConfig

Provides an automated way to change the value of isEnabled() on the ValueHost. To use, provide a Condition through its ConditionConfig object. When using, the initialEnabled property is ignored. The setEnabled() function will override this when setting it to false, while setting it to true will restore this condition.

Using the Builder API, use builder.enabler('valueHostName', (builder)=> builder.condition(parameters)).

Generated using TypeDoc v0.25.12