Library to assist in the development of security for form fields, with validation by RegEx, Sanitization and Mask in inputs.
npm:
$ npm install react-fieldsafe
yarn:
$ yarn add react-fieldsafe
import { useState } from 'react';
import { Validation } from 'react-fieldsafe';
export default function App() {
const [email, setEmail] = useState('[email protected]');
const submitForm = (e) => {
e.preventDefault();
const validator = new Validation();
const isEmail = validator.email(email);
console.log(isEmail) // true
}
return (
<div className="app">
<h1>React FieldSafe</h1>
<form method="POST" onSubmit={submitForm}>
<input
type="text"
onChange={(e) => setEmail(e.target.value)}
/>
<button>Submit</button>
</form>
</div>
);
};