instanceSchema: get rid of `any()` fields

environments/review-max-toot-c-50gs8j/deployments/4060
Alex Gleason 2023-09-26 12:29:35 -05:00
rodzic 4b52f20776
commit 0986055222
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 20 dodań i 3 usunięć

Wyświetl plik

@ -3,7 +3,8 @@ import z from 'zod';
import { accountSchema } from './account';
import { mrfSimpleSchema } from './pleroma';
import { coerceObject, mimeSchema } from './utils';
import { ruleSchema } from './rule';
import { coerceObject, filteredArray, mimeSchema } from './utils';
const configurationSchema = coerceObject({
chats: coerceObject({
@ -51,7 +52,11 @@ const pleromaSchema = coerceObject({
mrf_policies: z.string().array().optional().catch(undefined),
mrf_simple: mrfSimpleSchema,
}),
fields_limits: z.any(),
fields_limits: coerceObject({
max_fields: z.number().nonnegative().catch(4),
name_length: z.number().nonnegative().catch(255),
value_length: z.number().nonnegative().catch(2047),
}),
migration_cooldown_period: z.number().optional().catch(undefined),
restrict_unauthenticated: coerceObject({
activities: coerceObject({
@ -111,7 +116,7 @@ const instanceSchema = coerceObject({
nostr: nostrSchema.optional().catch(undefined),
pleroma: pleromaSchema,
registrations: z.boolean().catch(false),
rules: z.any(),
rules: filteredArray(ruleSchema),
short_description: z.string().catch(''),
stats: statsSchema,
thumbnail: z.string().catch(''),

Wyświetl plik

@ -0,0 +1,12 @@
import { z } from 'zod';
import { coerceObject } from './utils';
const ruleSchema = coerceObject({
id: z.string(),
text: z.string().catch(''),
});
type Rule = z.infer<typeof ruleSchema>;
export { ruleSchema, type Rule };