1.0.2 • Published 11 months ago

formite v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Formite

formite logo

A minimal and lightweight form library for Qwik

🐤 As tiny as 1 KB in size (gzipped)

🔀 Effortlessly works with your UI component libraries

🛡️ Easy validations with RegExp, Zod and custom functions

🚀 Designed with simplicity and performance in mind

Installation

npm install formite

Login form example

import { component$, useStore} from "@builder.io/qwik";
import Form, { ValidationStore } from "formite";

export const LoginForm = component$(() => {

  // a store defining the inputs we need to validate along with their validators
  const validationStore: ValidationStore = useStore({
    email: {
      validator: /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/, // or z.string().email()
    },
    password: {
      validator: /.{8,}/,
    },
  });

  return (
    <Form 
      validationStore={validationStore}
      onSubmit$={(formData)=>{/* send form data to server */}}>

      {/* email */}
      <div>
        Email: <input name="email" />

        {validationStore.email?.status === "invalid" && (
          <div>* Invalid email address</div>
        )}
      </div>

      {/* password */}
      <div>
        Password: <input name="password" type="password" />

        {validationStore.password?.status === "invalid" && (
          <div>* Password must have at least 8 characters</div>
        )}
      </div>

      {/* submit */}
      <button>Login</button>
    </Form>
  );
});

Have an issue? Post it here

1.0.2

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago