diff --git a/.changeset/bright-carrots-care.md b/.changeset/bright-carrots-care.md new file mode 100644 index 0000000000..84000ffb5c --- /dev/null +++ b/.changeset/bright-carrots-care.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-react': patch +--- + +Reverted the validation in depenendencies in scaffolder diff --git a/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.test.ts b/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.test.ts index 02e15ec53b..f4dab376bc 100644 --- a/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.test.ts +++ b/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.test.ts @@ -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(); - }); }); diff --git a/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.ts b/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.ts index b8ae3a6dfd..d11d0b9b3b 100644 --- a/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.ts +++ b/plugins/scaffolder-react/src/next/components/Stepper/createAsyncValidators.ts @@ -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); }