Reverted the validation in depenendencies in scaffolder
Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user