8000 Add null to condition value type · optimizely/javascript-sdk@c91fd6f · GitHub
[go: up one dir, main page]

Skip to content

Commit c91fd6f

Browse files
committed
Add null to condition value type
1 parent 026ccce commit c91fd6f

File tree

1 file changed

+3
-3
lines changed
  • packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator

1 file changed

+3
-3
lines changed

packages/optimizely-sdk/lib/core/custom_attribute_condition_evaluator/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type Condition = {
4141
name: string;
4242
type: string;
4343
match?: string;
44-
value: string | number | boolean;
44+
value: string | number | boolean | null;
4545
}
4646

4747
type ConditionEvaluator = (condition: Condition, userAttributes: UserAttributes) => boolean | null;
@@ -180,7 +180,7 @@ function greaterThanEvaluator(condition: Condition, userAttributes: UserAttribut
180180
const userValueType = typeof userValue;
181181
const conditionValue = condition.value;
182182

183-
if (!isSafeInteger(conditionValue)) {
183+
if (conditionValue === null || !isSafeInteger(conditionValue)) {
184184
logger.warn(
185185
LOG_MESSAGES.UNEXPECTED_CONDITION_VALUE, MODULE_NAME, JSON.stringify(condition)
186186
);
@@ -227,7 +227,7 @@ function lessThanEvaluator(condition: Condition, userAttributes: UserAttributes)
227227
const userValueType = typeof userValue;
228228
const conditionValue = condition.value;
229229

230-
if (!isSafeInteger(conditionValue)) {
230+
if (conditionValue === null || !isSafeInteger(conditionValue)) {
231231
logger.warn(
232232
LOG_MESSAGES.UNEXPECTED_CONDITION_VALUE, MODULE_NAME, JSON.stringify(condition)
233233
);

0 commit comments

Comments
 (0)
0