CI / changes (push) Successful in 10s
CI / commitlint (push) Has been skipped
CI / openapi (push) Successful in 27s
CI / web (push) Successful in 38s
CI / go (push) Successful in 2m36s
CI / bird2 (push) Successful in 15s
CI / release (push) Failing after 3m7s
Refactored the project structure to support a monorepo setup, moving the web application to `apps/web/` and updating related configurations. Adjusted pre-commit hooks to use `pnpm` for linting and formatting. Updated CI workflows to reflect the new directory structure and dependencies. Removed legacy files and configurations from the previous `web/` directory, streamlining the project for better maintainability and clarity.
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { z } from 'zod';
|
|
|
|
/** 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;
|
|
const ttl = Number(s);
|
|
return /^\d+$/.test(s) && Number.isInteger(ttl) && ttl >= 15 && ttl <= 43200;
|
|
},
|
|
{ message: 'TTL ревизий должен быть целым числом от 15 до 43200 минут' }
|
|
)
|
|
);
|
|
|
|
export const revisionSettingsSchema = z.object({
|
|
revision_retention_minutes: revisionRetentionMinutes
|
|
});
|
|
|
|
export type RevisionSettingsForm = z.infer<typeof revisionSettingsSchema>;
|
|
|
|
export const emptyRevisionSettingsForm = (): RevisionSettingsForm => ({
|
|
revision_retention_minutes: ''
|
|
});
|