You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
686 B

import { z } from "zod";
export const jsonFormatterConfigSchema = z.object({
maxInputLength: z.number().int().positive().max(1048576).default(102400),
indent: z.number().int().positive().max(8).default(2),
});
export type JsonFormatterToolConfig = z.infer<typeof jsonFormatterConfigSchema>;
export const DEFAULT_JSON_FORMATTER_CONFIG: JsonFormatterToolConfig = {
maxInputLength: 102400,
indent: 2,
};
export function parseJsonFormatterConfig(raw: unknown): JsonFormatterToolConfig {
const parsed = jsonFormatterConfigSchema.safeParse(raw);
if (!parsed.success) {
throw new Error(`Invalid json-formatter config: ${parsed.error.message}`);
}
return parsed.data;
}