refactor(server): use zod time validation (#29189)

This commit is contained in:
Timon
2026-06-18 13:56:02 +02:00
committed by GitHub
parent 83091d2834
commit 09d0380804
6 changed files with 11 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ class SystemConfigNightlyTasksDto {
/// Missing thumbnails
bool missingThumbnails;
/// Start time
/// Start time (HH:MM)
String startTime;
/// Sync quota usage

View File

@@ -26144,8 +26144,8 @@
"type": "boolean"
},
"startTime": {
"description": "Start time",
"pattern": "^([01]\\d|2[0-3]):[0-5]\\d$",
"description": "Start time (HH:MM)",
"pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d$",
"type": "string"
},
"syncQuotaUsage": {

View File

@@ -2501,7 +2501,7 @@ export type SystemConfigNightlyTasksDto = {
generateMemories: boolean;
/** Missing thumbnails */
missingThumbnails: boolean;
/** Start time */
/** Start time (HH:MM) */
startTime: string;
/** Sync quota usage */
syncQuotaUsage: boolean;

View File

@@ -70,7 +70,7 @@ describe(SystemConfigController.name, () => {
errorDto.validationError([
{
path: ['nightlyTasks', 'startTime'],
message: 'Invalid input: expected string in HH:mm format, received string',
message: 'Invalid input: expected string in HH:MM format, received string',
},
]),
);

View File

@@ -20,7 +20,6 @@ import {
VideoCodecSchema,
VideoContainerSchema,
} from 'src/enum';
import { isValidTime } from 'src/validation';
import z from 'zod';
/** Coerces 'true'/'false' strings to boolean, but also allows booleans. */
@@ -204,7 +203,12 @@ const SystemConfigNewVersionCheckSchema = z
const SystemConfigNightlyTasksSchema = z
.object({
startTime: isValidTime.describe('Start time'),
startTime: z.iso
.time({
precision: -1,
error: (iss) => `Invalid input: expected string in HH:MM format, received ${typeof iss.input}`,
})
.describe('Start time (HH:MM)'),
databaseCleanup: configBool.describe('Database cleanup'),
missingThumbnails: configBool.describe('Missing thumbnails'),
clusterNewFaces: configBool.describe('Cluster new faces'),

View File

@@ -188,10 +188,6 @@ export const isoDateToDate = z
)
.meta({ example: '2024-01-01' });
export const isValidTime = z
.string()
.regex(/^([01]\d|2[0-3]):[0-5]\d$/, 'Invalid input: expected string in HH:mm format, received string');
/**
* Latitude in range [-90, 90]. Reuse for body or query params.
*