Description
The ObjectComparator class allows you to perform a comparison over two values of any type.
Static methods
areEqual
Checks if two values are equal. The operation can be performed over values of any type.
public staticareEqual(value1: any, value2: any): boolean
- value1: any - first value to compare.
- value2: any - second value to compare.
- returns: boolean - true if values are equal and false otherwise.
areNotEqual
Checks if two values are NOT equal. The operation can be performed over values of any type.
public staticareNotEqual(value1: any, value2: any): boolean
- value1: any - first value to compare
- value2: any - second value to compare
- returns: boolean - true if values are NOT equal and false otherwise
compare
Perform a comparison operation over two arguments. The operation can be performed over values of any type.
public staticcompare(value1: any, operation: string, value2: any): boolean
- value1: any - first argument to compare.
- operation: string - comparison operation: "==" ("=", “EQ”), “!= " ("<>”, “NE”); “<"/">” (“LT”/“GT”), “<="/">=” (“LE”/“GE”); “LIKE”.
- value2: any - the second argument to compare.
- returns: boolean - result of the comparison operation.
isGreater
Checks if the first value is greater than the second one. The operation can be performed over numbers or strings.
public staticisGreater(value1: any, value2: any): boolean
- value1: any - first value to compare
- value2: any - second value to compare
- returns: boolean - true if the first value is greater than second and false otherwise.
isLess
Checks if first value is less than the second one. The operation can be performed over numbers or strings.
public staticisLess(value1: any, value2: any): boolean
- value1: any - first value to compare
- value2: any - second value to compare
- returns: boolean - true if the first value is less than second and false otherwise.
match
Checks if a string matches a regular expression
public staticmatch(value: any, regexp: any): boolean
- value: any - string value to match.
- regexp: any - regular expression string.
- returns: boolean - true if the value matches the regular expression and false otherwise.
Examples
ObjectComparator.compare(2, "GT", 1); // Result: true
ObjectComparator.areEqual("A", "B"); // Result: false