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