1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-04 00:18:01 +01:00

fix: constriants must have at least one value defined

closes #640
This commit is contained in:
Ivar Conradi Østhus 2020-10-30 16:40:29 +01:00
parent 9052a5a5df
commit 3c860d7bce
2 changed files with 15 additions and 9 deletions

View File

@ -8,12 +8,16 @@ const nameSchema = joi.object().keys({ name: nameType });
const constraintSchema = joi.object().keys({ const constraintSchema = joi.object().keys({
contextName: joi.string(), contextName: joi.string(),
operator: joi.string(), operator: joi.string(),
values: joi.array().items( values: joi
.array()
.items(
joi joi
.string() .string()
.min(1) .min(1)
.max(100), .max(100),
), )
.min(1)
.optional(),
}); });
const strategiesSchema = joi.object().keys({ const strategiesSchema = joi.object().keys({

View File

@ -220,7 +220,9 @@ test('should not accept empty list of constraint values', t => {
], ],
}; };
const { value, error } = featureShema.validate(toggle); const { error } = featureShema.validate(toggle);
t.deepEqual(value, toggle); t.deepEqual(
t.falsy(error); error.details[0].message,
'"strategies[0].constraints[0].values" must contain at least 1 items',
);
}); });