Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
480756d832 |
@@ -1,7 +1,18 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const revisionSettingsSchema = z.object({
|
||||
revision_retention_minutes: z.string().refine(
|
||||
/** HTML type=number binds number; API/store may return number — normalize to string for validation. */
|
||||
function retentionMinutesInput(val: unknown): string {
|
||||
if (val === undefined || val === null) return '';
|
||||
if (typeof val === 'number') {
|
||||
if (!Number.isFinite(val)) return '';
|
||||
return String(Math.trunc(val));
|
||||
}
|
||||
return String(val);
|
||||
}
|
||||
|
||||
const revisionRetentionMinutes = z.preprocess(
|
||||
retentionMinutesInput,
|
||||
z.string().refine(
|
||||
(v) => {
|
||||
const s = v.trim();
|
||||
if (s === '') return true;
|
||||
@@ -10,6 +21,10 @@ export const revisionSettingsSchema = z.object({
|
||||
},
|
||||
{ message: 'TTL ревизий должен быть целым числом от 15 до 43200 минут' }
|
||||
)
|
||||
);
|
||||
|
||||
export const revisionSettingsSchema = z.object({
|
||||
revision_retention_minutes: revisionRetentionMinutes
|
||||
});
|
||||
|
||||
export type RevisionSettingsForm = z.infer<typeof revisionSettingsSchema>;
|
||||
|
||||
Reference in New Issue
Block a user