Reverted the validation in depenendencies in scaffolder

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-01-28 22:52:15 +01:00
parent 915f0f3ba8
commit 656f67b491
3 changed files with 5 additions and 78 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Reverted the validation in depenendencies in scaffolder
@@ -435,62 +435,4 @@ describe('createAsyncValidators', () => {
expect(validators.CustomLinkField).toHaveBeenCalled();
});
it('should validate field in the dependencies in an array field', async () => {
const schema: JsonObject = {
title: 'Make a choice',
properties: {
myArray: {
type: 'array',
title: 'Array',
items: {
type: 'object',
required: ['selector'],
properties: {
selector: {
title: 'Selector',
type: 'string',
enum: ['Choice 1', 'Choice 2'],
},
},
dependencies: {
selector: {
oneOf: [
{ properties: { selector: { enum: ['Choice 1'] } } },
{
properties: {
selector: { enum: ['Choice 2'] },
customValidatedField: {
title: 'Custom validated field',
type: 'string',
'ui:field': 'ValidateKebabCase',
},
},
},
],
},
},
},
},
},
};
const validators = { ValidateKebabCase: jest.fn() };
const validate = createAsyncValidators(schema, validators, {
apiHolder: { get: jest.fn() },
});
await validate({
myArray: [
{
selector: 'Choice 2',
customValidatedField: 'apple',
},
{ selector: 'Choice 1' },
],
});
expect(validators.ValidateKebabCase).toHaveBeenCalled();
});
});
@@ -135,26 +135,6 @@ export const createAsyncValidators = (
for (const [, propValue] of Object.entries(properties)) {
await doValidate(propValue);
}
if (Array.isArray(value)) {
for (const [_, v] of Object.entries(value)) {
const { schema: itemSchema, uiSchema: itemUiSchema } =
extractSchemaFromStep(definitionInSchema.items);
if (isObject(v)) {
for (const [pK, pV] of Object.entries(v)) {
if ('ui:field' in itemUiSchema[pK]) {
await validateForm(
itemUiSchema[pK]['ui:field'],
pK,
pV,
itemSchema,
itemUiSchema,
);
}
}
}
}
}
} else if (isObject(value)) {
formValidation[key] = await validate(formData, pointer, value);
}