backend: update theme name validation to allow uppercase letters

This commit is contained in:
juancarmore 2025-09-30 12:17:32 +02:00
parent 67dfd5df63
commit 0a97f05c58
2 changed files with 5 additions and 8 deletions

View File

@ -99,7 +99,7 @@ const RoomThemeSchema = z.object({
.string()
.min(1, 'Theme name cannot be empty')
.max(50, 'Theme name cannot exceed 50 characters')
.regex(/^[a-z0-9_-]+$/, 'Theme name can only contain lowercase letters, numbers, hyphens and underscores'),
.regex(/^[a-zA-Z0-9_-]+$/, 'Theme name can only contain letters, numbers, hyphens and underscores'),
enabled: z.boolean(),
baseTheme: ThemeModeSchema,
backgroundColor: hexColorSchema.optional(),

View File

@ -182,12 +182,9 @@ describe('Rooms Appearance Config API Tests', () => {
it('should reject when theme name has invalid characters', async () => {
const invalidNames = [
'Corporate Blue', // Uppercase and spaces
'dark-mode-2024!', // Exclamation mark
'theme.corporate', // Dot
'Dark_Mode', // Uppercase
'theme 1', // Space
'thème-français' // Accents
'Corporate Blue', // Spaces
'dark-mode.2024!', // Special characters
'thème_français' // Accents
];
for (const name of invalidNames) {
@ -206,7 +203,7 @@ describe('Rooms Appearance Config API Tests', () => {
expectValidationError(
response,
'appearance.themes.0.name',
'Theme name can only contain lowercase letters, numbers, hyphens and underscores'
'Theme name can only contain letters, numbers, hyphens and underscores'
);
}
});