Improved TeamNameFormSchema to be case insensitive (#102)

This commit is contained in:
Giancarlo Buomprisco
2025-01-03 11:49:20 +08:00
committed by GitHub
parent 9bdab95909
commit b8e1bf3c18
2 changed files with 5 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ const RESERVED_NAMES_ARRAY = [
/** /**
* @name TeamNameSchema * @name TeamNameSchema
*/ */
const TeamNameSchema = z export const TeamNameSchema = z
.string({ .string({
description: 'The name of the team account', description: 'The name of the team account',
}) })
@@ -23,7 +23,7 @@ const TeamNameSchema = z
.max(50) .max(50)
.refine( .refine(
(name) => { (name) => {
return !RESERVED_NAMES_ARRAY.includes(name); return !RESERVED_NAMES_ARRAY.includes(name.toLowerCase());
}, },
{ {
message: 'teams:reservedNameError', message: 'teams:reservedNameError',

View File

@@ -1,7 +1,9 @@
import { z } from 'zod'; import { z } from 'zod';
import { TeamNameSchema } from './create-team.schema';
export const TeamNameFormSchema = z.object({ export const TeamNameFormSchema = z.object({
name: z.string().min(1).max(255), name: TeamNameSchema,
}); });
export const UpdateTeamNameSchema = TeamNameFormSchema.merge( export const UpdateTeamNameSchema = TeamNameFormSchema.merge(