Skip to content

Commit

Permalink
added invalid runtime error and test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielva-monday committed Sep 26, 2024
1 parent 1308477 commit d17f49c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/services/__tests__/mondaycoderc-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ describe('mondaycodercSchema Validation', () => {
const data = { RUNTIME: 'Go', RUNTIME_VERSION: '2.0.0' };
expect(() => mondaycodercSchema.parse(data)).toThrow('Invalid RUNTIME_VERSION for the specified RUNTIME');
});

it('should invalidate an Unsupported Runtime', () => {
const data = { RUNTIME: 'Invalid', RUNTIME_VERSION: '1.0.0' };
expect(() => mondaycodercSchema.parse(data)).toThrow('Invalid Runtime');
});
});
10 changes: 7 additions & 3 deletions src/services/schemas/mondaycoderc-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { z } from 'zod';

export const mondaycodercSchema = z
.object({
RUNTIME: z.enum(['Python', 'Java', 'Go', 'PHP', 'Ruby', 'Nodejs', 'NETCore']).optional(),
RUNTIME: z
.enum(['Python', 'Java', 'Go', 'PHP', 'Ruby', 'Nodejs', 'NETCore'], {
errorMap: () => ({
message: 'Invalid Runtime. Supported runtimes are Python, Java, Go, PHP, Ruby, Nodejs, NETCore',
}),
})
.optional(),
RUNTIME_VERSION: z.string().optional(),
})
.refine(
Expand Down Expand Up @@ -36,8 +42,6 @@ export const mondaycodercSchema = z
return /^(6|7)\.\d+$/.test(data.RUNTIME_VERSION || '');
}
}

return true;
},
{
message: 'Invalid RUNTIME_VERSION for the specified RUNTIME',
Expand Down

0 comments on commit d17f49c

Please sign in to comment.