Skip to content

Commit b6781c4

Browse files
committed
fallback values of null make initialize throw now
1 parent cbfcb2c commit b6781c4

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

test/__snapshots__/feature-toggles.test.js.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,14 @@ exports[`feature toggles test basic apis initializeFeatureToggles warns for inva
255255
"test/feature_b": {
256256
"SOURCE": "RUNTIME",
257257
"TYPE": "string",
258+
"VALIDATIONS": [
259+
{
260+
"regex": ".+",
261+
},
262+
],
263+
"VALIDATIONS_REGEX": [
264+
/\\.\\+/,
265+
],
258266
},
259267
"test/feature_c": {
260268
"SOURCE": "RUNTIME",

test/feature-toggles.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,9 @@ describe("feature toggles test", () => {
321321
type: "boolean",
322322
},
323323
[FEATURE.B]: {
324-
fallbackValue: null, // null not allowed
324+
fallbackValue: "", // empty string not valid
325325
type: "string",
326+
validations: [{ regex: ".+" }],
326327
},
327328
[FEATURE.C]: {
328329
fallbackValue: "1", // type mismatch
@@ -357,7 +358,7 @@ describe("feature toggles test", () => {
357358
expect(outputFromErrorLogger(loggerSpy.warning.mock.calls)).toMatchInlineSnapshot(`
358359
"FeatureTogglesError: found invalid fallback values during initialization
359360
{
360-
validationErrors: '[{"featureKey":"test/feature_b","errorMessage":"value null is not allowed"},{"featureKey":"test/feature_c","errorMessage":"value \\\\"{0}\\\\" has invalid type {1}, must be {2}","errorMessageValues":["1","string","number"]}]'
361+
validationErrors: '[{"featureKey":"test/feature_b","errorMessage":"value \\\\"{0}\\\\" does not match validation regular expression {1}","errorMessageValues":["","/.+/"]},{"featureKey":"test/feature_c","errorMessage":"value \\\\"{0}\\\\" has invalid type {1}, must be {2}","errorMessageValues":["1","string","number"]}]'
361362
}"
362363
`);
363364
expect(loggerSpy.error).not.toHaveBeenCalled();

0 commit comments

Comments
 (0)