
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Reformify is a flexible, reusable form library for React that supports dynamic form generation, schema-driven validation, and easy integration with popular form validation libraries like Yup or Zod. This library allows you to build forms with minimal effort and full customization.
Yup
or Zod
for form validation.You can install Reformify via npm or yarn:
# Using npm
npm install reformify
# Using yarn
yarn add reformify
import React from 'react';
import { useForm } from 'react-hook-form';
import { FormGenerator } from 'reformify';
const formSchema = [
{ name: 'email', type: 'text', label: 'Email Address', validation: 'required|email' },
{ name: 'password', type: 'password', label: 'Password', validation: 'required|min:6' },
{ name: 'role', type: 'select', label: 'Role', options: [{ value: 'admin', label: 'Admin' }, { value: 'user', label: 'User' }] }
];
const App = () => {
const { register, handleSubmit, formState: { errors } } = useForm();
const onSubmit = (data: any) => {
console.log(data);
};
return (
<div>
<h1>Form Example</h1>
<form onSubmit={handleSubmit(onSubmit)}>
<FormGenerator
fields={formSchema}
register={register}
errors={errors}
/>
<button type="submit">Submit</button>
</form>
</div>
);
};
export default App;
FormGenerator Component
import React from 'react';
import FormFieldWrapper from './FormFieldWrapper';
interface FormGeneratorProps {
fields: any[];
register: any;
errors: any;
}
export const FormGenerator: React.FC<FormGeneratorProps> = ({ fields, register, errors }) => {
return (
<div>
{fields.map((field) => (
<FormFieldWrapper
key={field.name}
field={field}
register={register}
error={errors[field.name]}
/>
))}
</div>
);
};
fields (Array): Array of form field configurations, each containing name, type, label, validation, and options (for select fields). register (Function): register function from react-hook-form used for form field registration. errors (Object): Validation errors object from react-hook-form.
Reformify can work seamlessly with Yup validation schema. Here's how you can integrate it with your form.
npm install yup
import * as Yup from 'yup';
import { useForm } from 'react-hook-form';
import { FormGenerator } from 'reformify';
const validationSchema = Yup.object({
email: Yup.string().required('Email is required').email('Invalid email format'),
password: Yup.string().required('Password is required').min(6, 'Password must be at least 6 characters'),
role: Yup.string().required('Role is required')
});
const App = () => {
const { register, handleSubmit, formState: { errors } } = useForm({
resolver: yupResolver(validationSchema) // Using yupResolver for validation
});
const onSubmit = (data: any) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<FormGenerator
fields={formSchema}
register={register}
errors={errors}
/>
<button type="submit">Submit</button>
</form>
);
};
import { z } from 'zod';
import { useForm } from 'react-hook-form';
import { FormGenerator } from 'reformify';
const validationSchema = z.object({
email: z.string().email('Invalid email format').nonempty('Email is required'),
password: z.string().min(6, 'Password must be at least 6 characters').nonempty('Password is required'),
role: z.string().nonempty('Role is required')
});
const App = () => {
const { register, handleSubmit, formState: { errors } } = useForm({
resolver: zodResolver(validationSchema) // Using zodResolver for validation
});
const onSubmit = (data: any) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>
<FormGenerator
fields={formSchema}
register={register}
errors={errors}
/>
<button type="submit">Submit</button>
</form>
);
};
You can define custom validation rules for each field inside the validation property in the form schema. Supported rules include:
We welcome contributions! If you find a bug or want to add a feature, feel free to open an issue or a pull request. Email kunalkhare2004@gmail.com
FAQs
A reusable React form library with validation support.
The npm package reformify receives a total of 0 weekly downloads. As such, reformify popularity was classified as not popular.
We found that reformify demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.