sveltekit-superforms icon indicating copy to clipboard operation
sveltekit-superforms copied to clipboard

Effect.js schema File upload not working

Open JustKira opened this issue 8 months ago • 0 comments

Description Im facing issue where trying to define schema in Effect but i keep getting errors

Error: Missing annotation
at path: ["file"]
details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation
schema (Declaration): <declaration schema>
import { Schema } from 'effect';

export const GalaxySchema = Schema.Struct({
	name: Schema.String,
	description: Schema.String,
	image: Schema.URL
});

export type Galaxy = typeof GalaxySchema.Type;


export const CreateGalaxySchema = Schema.Struct({
	...GalaxySchema.omit('image').fields,
	file: Schema.instanceOf(File)
});
import type { Actions } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { superValidate } from 'sveltekit-superforms';
import { effect } from 'sveltekit-superforms/adapters';
import { CreateGalaxySchema } from '$lib/hono/galaxy';

export const load: PageServerLoad = async () => {
	const form = superValidate(effect(CreateGalaxySchema));
	// const form
};

export const actions: Actions = {
	default: async ({ locals, request }) => {
		const form = await superValidate(request, effect(CreateGalaxySchema));

		await locals.api.v0.galaxy.$post({
			form: form.data
		});
	}
};

for effect.js when i asked on there discord they said superform expect jsonSchema but not sure what does that mean?

JustKira avatar Mar 15 '25 21:03 JustKira