Skip to content

Commit

Permalink
Merge pull request #637 from open-formulieren/of-3797/fix-plugin-vali…
Browse files Browse the repository at this point in the history
…dator-in-repeating-groups

[OF#3797] Fix plugin validator concerning repeating groups
  • Loading branch information
sergei-maertens authored Jan 24, 2024
2 parents 646aa8c + 55a2fe8 commit 300e246
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/formio/validators/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const pluginsAPIValidator = {

const plugins = component.component.validate.plugins;
const {baseUrl} = component.currentForm?.options || component.options;
const {submissionUuid} = component.currentForm?.options.ofContext;
const {submissionUuid} =
component.currentForm?.options?.ofContext || component.options?.ofContext;

const promises = plugins.map(plugin => {
const url = `${baseUrl}validation/plugins/${plugin}`;
Expand Down
22 changes: 22 additions & 0 deletions src/jstests/formio/validators/pluginapivalidator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,28 @@ describe('The OpenForms plugins validation', () => {
}
});

test('tests expected errors are returned when currentForm is not part of the component', async () => {
mswServer.use(
phoneNumberValidations.mockInValidDutchPhonenumberPost,
phoneNumberValidations.mockInValidInternationalPhonenumberPost
);

const component = {
component: phoneNumberComponent,
options: {
baseUrl: BASE_URL,
ofContext: {
submissionUuid: 'dummy',
},
},
};

for (const sample of inValidSamples) {
const result = await pluginsAPIValidator.check(component, undefined, sample);
expect(result).toBe('Invalid international phone number<br>Invalid dutch phone number');
}
});

test('tests no errors are returned when phone number is valid', async () => {
mswServer.use(
phoneNumberValidations.mockValidDutchPhonenumberPost,
Expand Down

0 comments on commit 300e246

Please sign in to comment.