Interface SupportsDataTypeConverter

Conditions that compare values using dataTypeComparerService.compare() will provide LookupKeys from the ValueHost.dataType. Often the comparison needs a little more work done to the value. Examples:

  • Case insensitive comparison needs to convert the strings to lowercase
  • Dates may be compared to each other as the difference between two in days, months, or years. Conversion would get the total days/months/years (instead of milliseconds). Implement this interface to provide conversionLookupKey to the ConditionConfig. If conversionLookupKey is assigned, pass it to compareValues() instead of ValueHost.dataType. Some LookupKeys that might be used: CaseInsensitive, Integer, TotalDays
interface SupportsDataTypeConverter {
    conditionType: string;
    category?: ConditionCategory;
    conversionLookupKey?: null | string;
}

Hierarchy (view full)

Properties

conditionType: string

Identifies the class for ConditionFactory to create. It is also used as the Validator's errorCode when ValidatorConfig.errorCode was not assigned.

Most Condition classes have an official value for Category. This allows you to override that official value in special situations and supply a value when the Condition does not.

conversionLookupKey?: null | string

Assign to a LookupKey of the data type you want the current value to be converted to before comparing. Examples:

  • case insensitive matching, use LookupKey.CaseInsensitive,
  • rounding a number to an integer, use LookupKey.Integer,
  • just the Day or Month or any other number in a Date object, use LookupKey.Day, LookupKey.Month, LookupKey.Year, etc.
  • a calculated value derived from the value, like the total days represented by a Date object, use LookupKey.TotalDays.

Generated using TypeDoc v0.25.12