New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@meronex/form

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meronex/form

Very simple react form validation component for React Material UI (and potential other)

  • 1.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-70%
Maintainers
1
Weekly downloads
 
Created
Source

Meronex Form

A very simple React forms validation for React MUI.

🚧 Note that this an early version and still being tested, feel free to open any issue_

demo

Features

  • Validate onBlur or onChange
  • Same API for classes and functional components
  • Easy to fork and modify to your needs

Usage

  1. Install npm i @meronex/form

  2. Import import Form from '@meronex/form';

  3. Add the form <Form ref={validatedForm} onUpdate={(_formData) => { setFormData(_formData); }} blurDelay={500}> ... React MUI Fields Here </Form

    Notice that we've a ref attached which exposes a validatedForm.reset() method and we've an onUpdate method which is triggered every time there change to the form. The blurDelay default is zero, and it used to delay blur validation to allow time for animation etc.

  4. Add the @material-ui fields with name, defaultValue and validator attribute.

    <TextField name={'name'} label="Name" defaultValue={'a'} validate={(v) => { if (!v || v === '') return 'Name is required..!!'; return true; }} />

    That's it! The onUpdate will be triggered with all the form data, you can then set it to the state object.

Why?

I wanted a validation component for few inputs I have, and I found the existing libraries to be either too complex or too rigid for my use case.

  1. Minimal and dead-simple API
  2. Minimal documentation/concepts
  3. Easy to fork and modify
  4. No dependencies

How it works?

The Form component will bind methods/props to the child fields. The value, onBlur, onChange, error and helperText props are automatically handled, a form object is created to capture the state of the form and that object is passed to the onUpdate method with every change.

Other libraries

  • Looking for React Icons? try Meronex Icons

Keywords

FAQs

Package last updated on 13 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc