Lookup Tables
Fig supports the concept of lookup tables. This is where a set of setting values supplied by a client can be used to create a dropdown to help the user select a valid value.
There are 2 potential use cases for this feature:
- Constraining the user to a set of valid values that are not known at the time of writing the application.
- Adding a helpful alias to dropdown values to make it easier to understand.
Valid Values
Fig has support for adding valid values in the application and this assists the user to input a valid value by constraining their choices to a set of valid options.
However, in some cases, the list of valid options is now known. Consider the case where an application integrates towards an external system. The external system has a configurable structure where types can be configured. The application does not know ahead of types which types will be configured, but these are known at runtime. A lookup table can be created containing all the configured types and then in the application configuration, a dropdown will be created with the types for use.
[Setting("Types defined in the system")]
[LookupTable("Types")]
public string? Types { get; set; }
With this lookup table defined:
Lookup table without an alias defined
The user gets a drop down list.
Dropdown defined by the lookup table
If the existing value is not in the list, it is added but marked as invalid.
If no lookup table is defined, the property is just handled as a normal string property.