# fomikon

> Make form validation easy and simple

Latest version **1.0.3** (published 2022-01-08) · Apache License 2.0 license · 0 weekly downloads

## Install

```sh
npm install fomikon
pnpm add fomikon
yarn add fomikon
bun add fomikon
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-01-08 |
| First published | 2022-01-06 |
| Weekly downloads | 0 |
| License | Apache License 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 15.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Yuhki Hayashi |
| Maintainers | yuhki_hayashi |
| Keywords | Form, React, Validation, Next, JavaScript |

## Links

- npm: https://www.npmjs.com/package/fomikon
- Repository: https://github.com/Cosmo2357/fomikon
- Homepage: https://github.com/Cosmo2357/fomikon#readme
- Issues: https://github.com/Cosmo2357/fomikon/issues
- npm.io page: https://npm.io/package/fomikon

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2022-01-08
- 1.0.2 — 2022-01-07
- 1.0.1 — 2022-01-06
- 1.0.0 — 2022-01-06

## README

<p align="center">
<img src="https://user-images.githubusercontent.com/37522195/148510942-f689f58f-ed82-4ce6-94e4-76aba2f8ee82.jpg"/>

<strong>😊Feel to contact me if you wanna join the project!<strong>

</p>

# 👾FOMIKON👾 Form validation library for React

Fomikon makes your stressful form validation work easy.
It returns the number depending on the status during form validation.

[Apache 2.0 License.](https://github.com/cosmo2357/fomikon/LICENSE)

# Author

- Yuhki Hayashi

# Contributors

- Who wanna be listed here? Feel free to message me! 😉

# How it works

By implementing fomikon, fomikon returns the number depending on if it's the input field.

for example

- user clicked the input => 2
- user type wrong email address and move to the next input => 3
- user fixed the email => 0

And there is a function that checks if all input fields are validated.
So, You can use this function to activate form submit button.

# Usage

## Installation

```bash
$ npm i fomikon
```

```javascript
import Fomikon from "fomikon";
```

```javascript
const fomikon = new Fomikon();
```

## Functions

```javascript
atOnFocus();
```

```javascript
atOnBlur();
```

```javascript
atUseEffect();
```

```javascript
atButtonDisable();
```

```javascript
// You can call function like this 😉
const fomikon = new Fomikon();
fomikon.atButtonDisable();
```

## Example

```javascript
import React, { useState , useEffect} from "react";

export default function FormExample() {
  // Create state of the input
  const [email, setEmail] = useState("");

  // Create state for the validation
  //note* Please set 0 if the email is required.
  // FOMIKON will change the number depending on the status of the input.
  const [emailValidation, setEmailValidation] = useState(1);

  const fomikon = new Fomikon();

  //You can specify the regex for the each validation here
  //Regex is very powerful tool.
  //So I recommend you to learn basic if you don't know anything 💪
  const mailRegex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;

  // Create array data and set it in each functions FOMIKON offers.
  const fomikonMail = [
    email,
    setEmail,
    emailValidation,
    setEmailValidation,
    { require: true, regex: mailRegex },
  ];

  // This is for atButtonDisable() function
  const buttonDisable = [emailValidation]

// Maybe you should use memo or useMemo or something like that if you care about performance. 🐢
  useEffect{()=> {
    fomikon.atUseEffect(fomikonMail)
  },[ email,
    setEmail,
    emailValidation,
    setEmailValidation, regex]}

  const submitHandler = () => {
    const data = { email: email };
    console.log(data);
  };


  return (
    <div>
      <input
        type="email"
        placeholder="email"
        value={email}
        onChange={(e) => {
          setEmail(e.target.value);
        }}
        onFocus={() => {
          fomikon.atOnFocus(...fomikonMail);
        }}
        onBlur={() => {
          fomikon.atOnBlur(...fomikonMail);
        }}
      />
      <button onClick={submitHandler}　
      disable={()=> {
        fomikon.atButtonDisable(buttonDisable)
      }} >SUBMIT</button>
    </div>
  );
}
```

Disable esLint chant for the Lazy developer🧙‍♂️

```javascript
// eslint-disable-next-line
```

👷Work in progress 👷

---
_Source: https://npm.io/package/fomikon · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
