Skip to content

Commit cdfe9e7

Browse files
committed
override behavior 3
1 parent b293161 commit cdfe9e7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/feature-toggles.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,6 @@ class FeatureToggles {
238238
if (this.__config[featureKey]) {
239239
switch (mergeConflictBehavior) {
240240
case CONFIG_MERGE_CONFLICT.OVERRIDE: {
241-
// TODO: you cannot just remove all validations, because registering validations before init is recommended
242-
// for programmatic validation
243-
this.removeAllFeatureValueValidation(featureKey);
244241
break;
245242
}
246243
case CONFIG_MERGE_CONFLICT.PRESERVE: {
@@ -313,7 +310,6 @@ class FeatureToggles {
313310

314311
if (validations) {
315312
this.__config[featureKey][CONFIG_KEY.VALIDATIONS] = validations;
316-
this._processValidations(featureKey, validations, sourceFilepath);
317313
}
318314
}
319315

@@ -337,7 +333,15 @@ class FeatureToggles {
337333
configRuntime
338334
);
339335

336+
// NOTE: this post-processing is easier to do after the config is merged
340337
this.__featureKeys = Object.keys(this.__fallbackValues);
338+
for (const featureKey of this.__featureKeys) {
339+
const validations = this.__config[featureKey][CONFIG_KEY.VALIDATIONS];
340+
if (validations) {
341+
const sourceFilepath = this.__config[featureKey][CONFIG_KEY.SOURCE_FILEPATH];
342+
this._processValidations(featureKey, validations, sourceFilepath);
343+
}
344+
}
341345

342346
this.__isConfigProcessed = true;
343347
return {

0 commit comments

Comments
 (0)