
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
json-msg-react
Advanced tools
This might be similar to Formik but in a hook form , and this is also use json-msg as a validator. Json-msg is a lightweight alternative for yup and joi or any other schema validator.
Check json-msg documentation here
npm install json-msg-react
or
yarn add json-msg-react
import React from "react";
import jm, { useForm } from "json-msg-react";
const schema = {
username: jm.str({ min: 5 }),
password: jm.str({ min: 8, max: 40 }),
pin: jm.num({ digit: 4 }),
};
const initialData = {
username: "",
password: "",
pin: 0,
};
const Example = () => {
const { handleChange, handleSubmit, errors } = useForm(initialData, schema);
function submit(data) {
console.log(data);
}
return (
<>
<form onSubmit={handleSubmit(submit)}>
<input name="username" onChange={handleChange} />
{errors.username && <p> {errors.username} </p>}
<input name="password" type="password" onChange={handleChange} />
{errors.username && <p> {errors.username} </p>}
<input name="pin" type="number" onChange={handleChange} />
{errors.password && <p> {errors.password} </p>}
</form>
</>
);
};
| option | type | default | description |
|---|---|---|---|
| showAllErrors | boolean | false | Show all the errors in array form |
| trim | boolean | false | Trim all the string in the data |
| validateOnChange | boolean | true | Validate on change the data |
| validateOnMount | boolean | false | Validate the data on mount |
FAQs
Make form validation easier
We found that json-msg-react demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.