mirror of
https://github.com/graphql-hive/console
synced 2026-05-22 08:38:27 +00:00
Fix validation of git repository identifier in updateProjectGitRepository (#137)
Validation logic of the git repository field in the project's settings expected an URL instead of the `owner/name` format
This commit is contained in:
parent
068d018c54
commit
29552a575f
1 changed files with 5 additions and 1 deletions
|
|
@ -8,6 +8,10 @@ import { z } from 'zod';
|
|||
|
||||
const ProjectNameModel = z.string().min(2).max(40);
|
||||
const URLModel = z.string().url().max(200);
|
||||
const RepoOwnerWithNameModel = z
|
||||
.string()
|
||||
.regex(/^[^/]+\/[^/]+$/, 'Expected owner/name format')
|
||||
.max(200);
|
||||
const MaybeModel = <T extends z.ZodType>(value: T) => z.union([z.null(), z.undefined(), value]);
|
||||
|
||||
export const resolvers: ProjectModule.Resolvers & { ProjectType: any } = {
|
||||
|
|
@ -137,7 +141,7 @@ export const resolvers: ProjectModule.Resolvers & { ProjectType: any } = {
|
|||
},
|
||||
async updateProjectGitRepository(_, { input }, { injector }) {
|
||||
const UpdateProjectGitRepositoryModel = z.object({
|
||||
gitRepository: MaybeModel(URLModel),
|
||||
gitRepository: MaybeModel(RepoOwnerWithNameModel),
|
||||
});
|
||||
|
||||
const result = UpdateProjectGitRepositoryModel.safeParse(input);
|
||||
|
|
|
|||
Loading…
Reference in a new issue