Skip to content

Errors store doesn`t reflect errors from validate function #311

Description

@ravecat

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

  1. Clone demo branch
git clone -b demo_felte_errors git@github.com:ravecat/runa.git
  1. Install dependencies with:
mix setup
  1. Start development server:
mix phx.server
  1. Login (click Contonue woth Google)
  2. Visit http://localhost:4000/team
  3. Form available under Add member button and errors reflected by $derived runa instead of error-store from createForm

Image

Image

For example, isValid store reflects errors and disable button som lines below

Small reproduction example

No response

Screenshots

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions