diff --git a/src/__tests__/if-run/lib/regroup.test.ts b/src/__tests__/if-run/lib/regroup.test.ts index 9f0b373ff..67ff72e53 100644 --- a/src/__tests__/if-run/lib/regroup.test.ts +++ b/src/__tests__/if-run/lib/regroup.test.ts @@ -86,7 +86,7 @@ describe('lib/regroup: ', () => { expect(error).toBeInstanceOf(InputValidationError); expect(error).toEqual( new InputValidationError( - '"groups" parameter is required. Error code: invalid_type.' + '"regroup" parameter is not an array or should contain at least one key. Error code: invalid_type.' ) ); } @@ -135,7 +135,7 @@ describe('lib/regroup: ', () => { expect(error).toBeInstanceOf(InputValidationError); expect(error).toEqual( new InputValidationError( - '"groups" parameter is regroup phase is not an array or should contain at least one key.. Error code: too_small.' + '"regroup" parameter is array must contain at least 1 element(s). Error code: too_small.' ) ); } diff --git a/src/if-run/config/strings.ts b/src/if-run/config/strings.ts index 24835f8ed..e5e6e449b 100644 --- a/src/if-run/config/strings.ts +++ b/src/if-run/config/strings.ts @@ -24,8 +24,7 @@ export const STRINGS = { METRIC_MISSING: (metric: string, index: number) => `Aggregation metric ${metric} is not found in inputs[${index}].`, INVALID_GROUP_KEY: (key: string) => `Invalid group ${key}.`, - REGROUP_ERROR: - 'Regroup phase is not an array or should contain at least one key.', + REGROUP_ERROR: 'not an array or should contain at least one key', INVALID_EXHAUST_PLUGIN: (pluginName: string) => `Invalid exhaust plugin: ${pluginName}.`, UNKNOWN_PARAM: (name: string) => diff --git a/src/if-run/lib/regroup.ts b/src/if-run/lib/regroup.ts index eba87a4d0..affd51307 100644 --- a/src/if-run/lib/regroup.ts +++ b/src/if-run/lib/regroup.ts @@ -44,12 +44,13 @@ export const Regroup = (inputs: PluginParams[], groups: string[]) => { /** * Validates groups array. */ - const validateGroups = (groups: string[]) => { - const inputData = {groups}; + const validateGroups = (regroup: string[]) => { + const inputData = {regroup}; const validationSchema = z.record( z.string(), - z.array(z.string()).min(1, REGROUP_ERROR) + z.array(z.string(), {message: REGROUP_ERROR}).min(1) ); + validate(validationSchema, inputData); return groups;