Incorporated a feedback

Signed-off-by: bnechyporenko <bnechyporenko@bol.com>
This commit is contained in:
bnechyporenko
2023-02-06 14:05:02 +01:00
parent 074f7e81b5
commit 8c63cebe70
3 changed files with 17 additions and 16 deletions
+1 -1
View File
@@ -2,4 +2,4 @@
'@backstage/plugin-circleci': patch
---
Making workflow a link
Making workflow a link
@@ -32,17 +32,20 @@ describe('createValidator', () => {
}
},
TagPicker: (
value: unknown,
values: unknown,
fieldValidation: FieldValidation,
_context: { apiHolder: ApiHolder },
) => {
if (!value) {
const input = values as string[];
if (input.length === 0) {
fieldValidation.addError('A tag name can not be empty');
}
if (!/^[a-z0-9-]+$/.test(value as string)) {
fieldValidation.addError(
'A tag name can only contain lowercase letters, numeric characters or dashes',
);
for (const item of input) {
if (!/^[a-z0-9-]+$/.test(item)) {
fieldValidation.addError(
'A tag name can only contain lowercase letters, numeric characters or dashes',
);
}
}
},
};
@@ -63,15 +63,13 @@ export const createValidator = (
if (isObject(propSchemaProps)) {
const { items } = propSchemaProps;
if (isObject(items)) {
for (const propItem of propData as JsonObject[]) {
const fieldName = items['ui:field'] as string;
if (fieldName && typeof validators[fieldName] === 'function') {
validators[fieldName]!(
propItem as JsonValue,
propValidation,
context,
);
}
const fieldName = items['ui:field'] as string;
if (fieldName && typeof validators[fieldName] === 'function') {
validators[fieldName]!(
propData as JsonObject[],
propValidation,
context,
);
}
}
}