Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kdy1/react-forms

Smart validation for react
https://github.com/kdy1/react-forms

Last synced: 26 days ago
JSON representation

Smart validation for react

Awesome Lists containing this project

README

        

# React form

## Usage

### Simple usage

If you **don't use** forms from `@material-ui/core`, run

```js
npm i -S react-forms-base
```

```ts
// TODO
```

### Material form fields

If you **use** `@material-ui/core`, you can easily add validation logic to a `TextField`.

```js
npm i -S react-forms-base react-material-fields
```

```ts
import { Form } from "react-forms-base";
import { useFormState } from "react-use-form-state";
import { TextFormField } from "react-material-fields/lib/TextFormField";

const MyForm: React.FC = () => {
// This part is optional. You can your own `onChange` and `value`.
const [form, { text }] = useFormState({});

return (

{
if (!v) {
return "Enter name of the app";
}
}}
/>

{
if (!v) return "Please enter id of the app";
if (v.length < 3)
return "ID of the app should be at least 3 characters";
}}
/>

Create

);
};
```

![Validation of id](./validation.png)