Class that compares two values to determine equality, less than, greater than. Create classes for each data type that doesn't support the ==, !=, <, > operators the desired way. However, first consider using an IDataTypeConverter to convert your data type into an integer, string, or date. Those will be supported by the default comparer.

Register your implementation with ValidationServices.dataTypeComparerService.

interface IDataTypeComparer {
    supportsValues(value1, value2, lookupKey1, lookupKey2): boolean;
    compare(value1, value2, lookupKey1, lookupKey2): ComparersResult;
}

Implemented by

Methods

  • Determines if this Comparer supports the inputs. Do not call compare() if this returns false.

    Parameters

    • value1: any

      The first value to compare.

    • value2: any

      The second value to compare.

    • lookupKey1: null | string

      A lookup key indicating how to interpret value1 or null if no such hint is needed.

    • lookupKey2: null | string

      A lookup key indicating how to interpret value2 or null if no such hint is needed.

    Returns boolean

  • Performs the comparison. It has 3 possible outcomes:

    • Using Equal, LessThan and GreaterThan when both values can be compared relative to the other.
    • Using Equal and NotEqual when the values don't make sense as LessThan or GreaterThan, such as with booleans.
    • Using Undetermined when either of the values are not supported.

    Parameters

    • value1: any
    • value2: any
    • lookupKey1: null | string
    • lookupKey2: null | string

    Returns ComparersResult

Generated using TypeDoc v0.25.12