felte
felte copied to clipboard
Errors store doesn`t reflect errors from validate function
Describe the bug
Thanks for the handy library, I decided to introduce it into the project, however, I ran into the error that errors store doesn't reflects errors returned from async validate function
Instead that errors based on $derived rune from props. But probably I do something wrong
...
import { createForm } from "felte";
type Props = LiveSvelteProps<{
team: Form<Team>;
roles: Contributor["role"][];
invite: Form<ContributorInvite>;
}>;
let { team, roles, live, invite }: Props = $props();
// Form helper below doesn't reflect the actual from errors
// so we need to derive the errors from props
let errors = $derived(invite.errors);
let { form, data, isValid } = createForm<ContributorInvite>({
onSubmit: (values, { setData }) => {
live?.pushEvent("invite_contributors", values);
setData(invite.data);
},
initialValues: invite.data,
validate: async (values) => {
return new Promise((resolve) => {
live?.pushEvent("validate_contributors", values, ({ errors }) => {
resolve(errors);
});
});
},
});
...
Made a demo branhc with reproducible issue below.
Which package/s are you using?
felte (Svelte)
Environment
- OS: fedora
- Browser: brave
- Version: 1.3.0
To reproduce
- Clone demo branch
git clone -b demo_felte_errors [email protected]:ravecat/runa.git
- Install dependencies with:
mix setup
- Start development server:
mix phx.server
- Login (click
Contonue woth Google) - Visit http://localhost:4000/team
- Form available under
Add memberbutton and errors reflected by$derivedruna instead oferror-store fromcreateForm
For example, isValid store reflects errors and disable button som lines below
Small reproduction example
No response
Screenshots
No response
Additional context
No response