1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +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({
contextName: joi.string(),
operator: joi.string(),
values: joi.array().items(
joi
.string()
.min(1)
.max(100),
),
values: joi
.array()
.items(
joi
.string()
.min(1)
.max(100),
)
.min(1)
.optional(),
});
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);
t.deepEqual(value, toggle);
t.falsy(error);
const { error } = featureShema.validate(toggle);
t.deepEqual(
error.details[0].message,
'"strategies[0].constraints[0].values" must contain at least 1 items',
);
});