instanceSchema: get rid of any()
fields
This commit is contained in:
parent
4b52f20776
commit
0986055222
2 changed files with 20 additions and 3 deletions
|
@ -3,7 +3,8 @@ import z from 'zod';
|
||||||
|
|
||||||
import { accountSchema } from './account';
|
import { accountSchema } from './account';
|
||||||
import { mrfSimpleSchema } from './pleroma';
|
import { mrfSimpleSchema } from './pleroma';
|
||||||
import { coerceObject, mimeSchema } from './utils';
|
import { ruleSchema } from './rule';
|
||||||
|
import { coerceObject, filteredArray, mimeSchema } from './utils';
|
||||||
|
|
||||||
const configurationSchema = coerceObject({
|
const configurationSchema = coerceObject({
|
||||||
chats: coerceObject({
|
chats: coerceObject({
|
||||||
|
@ -51,7 +52,11 @@ const pleromaSchema = coerceObject({
|
||||||
mrf_policies: z.string().array().optional().catch(undefined),
|
mrf_policies: z.string().array().optional().catch(undefined),
|
||||||
mrf_simple: mrfSimpleSchema,
|
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),
|
migration_cooldown_period: z.number().optional().catch(undefined),
|
||||||
restrict_unauthenticated: coerceObject({
|
restrict_unauthenticated: coerceObject({
|
||||||
activities: coerceObject({
|
activities: coerceObject({
|
||||||
|
@ -111,7 +116,7 @@ const instanceSchema = coerceObject({
|
||||||
nostr: nostrSchema.optional().catch(undefined),
|
nostr: nostrSchema.optional().catch(undefined),
|
||||||
pleroma: pleromaSchema,
|
pleroma: pleromaSchema,
|
||||||
registrations: z.boolean().catch(false),
|
registrations: z.boolean().catch(false),
|
||||||
rules: z.any(),
|
rules: filteredArray(ruleSchema),
|
||||||
short_description: z.string().catch(''),
|
short_description: z.string().catch(''),
|
||||||
stats: statsSchema,
|
stats: statsSchema,
|
||||||
thumbnail: z.string().catch(''),
|
thumbnail: z.string().catch(''),
|
||||||
|
|
12
src/schemas/rule.ts
Normal file
12
src/schemas/rule.ts
Normal file
|
@ -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 };
|
Loading…
Reference in a new issue