2.0.0 • Published 3 months ago
ic-operator-validation v2.0.0
IC-OPERATOR-VALIDATION
This lib compares and validates two values you provide.
After importing the lib, for the implementation we need to:
Instance class OperatorValidator with the following parameters
{
type_of_value: string,
value: unknown,
value_to_compare: unknown,
operator?: string // if empty it's going to consider 'EQUALS'
}
The values for type_of_value
can be:
'string', 'boolean', 'number', 'date', 'datetime'
The values for operator
can be:
'EQUALS', 'DIFF', 'STARTING', 'ENDING', 'BIGGER', 'MINOR', 'BIGGEREQ', 'MINOREQ', 'IN', 'NOT_IN', 'HAS_DAY', 'HAS_MONTH', 'HAS_YEAR', 'IN_WEEK'
Call OperatorValidator.compare()
It will return a boolean
telling you if the values you are comparing match the operator you defined.
True means it matches and false means it doesn't.