/** * Copyright 2017 Yahoo Holdings Inc. * Licensed under the terms of the MIT license. See LICENSE file in project root for terms. */ export declare class Condition { /** * Evaluate one condition against provided test value. * * @param {} condition The rule that the test value must satisfy * @param {} testValue The data about the user that corresponds to the conditionValue. If this * testValue satisfies the condition, return TRUE. * @param {Object} customEvaluators Contains the names of evaluators as keys and the functions as values * * @return {Boolean} TRUE if it matches, FALSE if it doesn't. * * @example: returns true, because the provided farm is included in the list. * `evaluate('farm', ['123', '456', '789'], { farm: '123' });` */ static evaluate(condition: any, testValue: any, customEvaluators?: Record): any; /** * Identify the type of the rule that is provided in the except block. * * @param {} condition in an except block * @return {String} one of the CONDITION_TYPES */ private static _getConditionType; /** * Check if primitive data types match. * * @param {Number, String, Boolean} condition The value of the condition * @param {Number, String, Boolean} testValue The value to check against the condition. * * @return {Boolean} TRUE if the values equal each other, FALSE if not. */ private static _checkPrimitive; /** * @example * the context object is { locale: 'en' } * * the configuration entry is * * except: [{ * enabled: false, * locale: ['en', 'br'] * }] * * The function will be evaluating a single enum context field of the except block against provided value in the * `context` object. * * @param {Array} condition The value of the condition * @param {} testValue The value to check against the condition. * This could be a single value or an array of any value type. * * @return {Boolean} TRUE if the context contains a valid value, FALSE if the context does not. */ private static _checkEnum; /** * @example * the context object is { farm: 1201 } * * the configuration entry is * ``` * except: [{ * enabled: false, * farm: [9323, '1200-1205'] * }] * ``` * The function will evaluate a single range entry (element) against provided value from the * `context` object (testValue). We determine if the number is in the range. Both increasing * '1200..1205' and decreasing 'reversed') '1205..1200' are supported. * The range can be inclusive '..' or exclusive '...'. Negative range endpoints are also supported. * * @param {string} element The integer range to check against. * @param {number} testValue The value to check against the condition. * * @return {Boolean} TRUE if the context contains a valid value that is in the given range, * FALSE if the context does not. */ private static _checkRange; /** * Evaluate a context field against a custom evaluator. * * @param {Object} The value of the condition, containing: * {String} evaluator, which maps to a function in customEvaluators * {} dimensionValue, which is what the testValue is tested against in the custom evaluator * @param {} testValue The value to check against the condition. * @param {Object} customEvaluators Contains the names of evaluators as keys and the functions as values * Basically, condition.evaluator should be the key to this object. * * @return {Boolean} TRUE if the custom evaluator passed, FALSE if the custom evaluator did not pass */ private static _checkCustomEvaluator; }