mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 18:05:11 +00:00
Fix #80536
This commit is contained in:
parent
d163340556
commit
55825e9ad2
2 changed files with 13 additions and 0 deletions
|
@ -1043,6 +1043,13 @@ export function createValidator(prop: IConfigurationPropertySchema): (value: any
|
|||
|
||||
const stringArrayValue = value as string[];
|
||||
|
||||
if (prop.uniqueItems) {
|
||||
if (new Set(stringArrayValue).size < stringArrayValue.length) {
|
||||
message += nls.localize('validations.stringArrayUniqueItems', 'Array has duplicate items');
|
||||
message += '\n';
|
||||
}
|
||||
}
|
||||
|
||||
if (prop.minItems && stringArrayValue.length < prop.minItems) {
|
||||
message += nls.localize('validations.stringArrayMinItem', 'Array must have at least {0} items', prop.minItems);
|
||||
message += '\n';
|
||||
|
|
|
@ -328,4 +328,10 @@ suite('Preferences Model test', () => {
|
|||
|
||||
arr.rejects(['a']).withMessage(`err: must be friendly`);
|
||||
});
|
||||
|
||||
test('uniqueItems', () => {
|
||||
const arr = new ArrayTester({ type: 'array', items: { type: 'string' }, uniqueItems: true });
|
||||
|
||||
arr.rejects(['a', 'a']).withMessage(`Array has duplicate items`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue