27 lines
634 B
TypeScript
27 lines
634 B
TypeScript
import { z } from '@/deps.ts';
|
|
|
|
const jsonSchema = z.string().transform((value, ctx) => {
|
|
try {
|
|
return JSON.parse(value);
|
|
} catch (_e) {
|
|
ctx.addIssue({ code: z.ZodIssueCode.custom, message: 'Invalid JSON' });
|
|
return z.NEVER;
|
|
}
|
|
});
|
|
|
|
const optionalString = z.string().optional().catch(undefined);
|
|
|
|
const metaContentSchema = z.object({
|
|
name: optionalString,
|
|
about: optionalString,
|
|
picture: optionalString,
|
|
banner: optionalString,
|
|
nip05: optionalString,
|
|
lud16: optionalString,
|
|
});
|
|
|
|
type MetaContent = z.infer<typeof metaContentSchema>;
|
|
|
|
export { jsonSchema, metaContentSchema };
|
|
export type { MetaContent };
|