npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dynamic-react-forms

v1.5.1

Published

This is React Dynamic Form which enables you to build a set of ready made validation forms.

Readme

npm downloads npm npm Discord

Features

  • This package is very helpful for generating dynamic forms. You don’t have to worry about HTML validation management;
  • you only need to pass an array with your fields, and it will automatically generate the content for your form along with validation according to your specifications.

Install

npm i dynamic-react-forms 

Quickstart


// Install the yup for validation

   npm i yup  

// for  Form inputs  you have to pass the array 

import React from 'react'
import DynamicForm from "dynamic-react-forms"; 
import * as Yup from 'yup';
 

const formConfig = [
  // 1st Row: 2 Input Text
  [
    {
      name: 'username',
      type: 'text',
      placeholder: 'Enter your username',
      className: 'username-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      yup: [Yup.string().required('Username is required').min(5, 'Minimum 5 characters').max(15, 'Maximum 15 characters')],
    },
    {
      name: 'email',
      type: 'email',
      placeholder: 'Enter your email',
      className: 'email-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      yup: [Yup.string().required('Email is required').email('Invalid email address')],
    },
  ], 
];


const handleSubmit = (data) => {
  console.log(data);
  //You can use write your logic  . or API Call
};

function App() {
  return (
    <div className="container mt-5">
      <DynamicForm formConfig={formConfig} onSubmit={handleSubmit} />
    </div>
  );
}

export default App;
import React from 'react'
import DynamicForm from "dynamic-react-forms"; 
import * as Yup from 'yup';
 

const formConfig = [
  // 1st Row: 2 Input Text
  [
    {
      name: 'username',
      type: 'text',
      placeholder: 'Enter your username',
      className: 'username-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      yup: [Yup.string().required('Username is required').min(5, 'Minimum 5 characters').max(15, 'Maximum 15 characters')],
    },
    {
      name: 'email',
      type: 'email',
      placeholder: 'Enter your email',
      className: 'email-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      yup: [Yup.string().required('Email is required').email('Invalid email address')],
    },
  ],
  // 2nd Row: 3 Input Number
  [
    {
      name: 'age',
      type: 'number',
      placeholder: 'Enter your age',
      className: 'age-field',
      readOnly: false,
      hidden: false,
      minValue:0,
      value: '', // Default value
      yup: [Yup.string().required('Age is required')],
    },
    {
      name: 'height',
      type: 'number',
      placeholder: 'Enter your height (cm)',
      className: 'height-field',
      readOnly: false,
      hidden: false,
      minValue:0,
      value: '', // Default value
      yup: [Yup.string().required('Height is required') ],
    },
    {
      name: 'weight',
      type: 'number',
      placeholder: 'Enter your weight (kg)',
      className: 'weight-field',
      readOnly: false,
      hidden: false,
      minValue:0,
      value: '', // Default value
      yup: [Yup.string().required('Weight is required') ],
    },
  ],
  // 3rd Row: 3 Input File 
  [
    {
      name: 'gender',
      type: 'select',
      placeholder: 'Select your gender',
      className: 'gender-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      options: ['Male', 'Female', 'Other'],
      yup: [Yup.string().required('Gender is required')],
    },
    {
      name: 'country',
      type: 'select',
      placeholder: 'Select your country',
      className: 'country-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      options: ['USA', 'Canada', 'UK', 'Other'],
      yup: [Yup.string().required('Country is required')],
    },
    {
      name: 'feedbackType',
      type: 'select',
      placeholder: 'Select feedback type',
      className: 'feedback-type-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      options: ['Complaint', 'Suggestion', 'Inquiry'],
      yup: [Yup.string().required('Feedback type is required')],
    },
  ],
  // 4th Row: 1 Textarea
  [
    {
      name: 'feedback',
      type: 'textarea',
      placeholder: 'Your feedback',
      className: 'feedback-field',
      readOnly: false,
      hidden: false,
      value: '', // Default value
      yup: [Yup.string().required('Feedback is required')],
    },
  ],
];


const handleSubmit = (data) => {
  console.log(data);
  //You can use write your logic  . or API Call
};

function App() {
  return (
    <div className="container mt-5">
      <DynamicForm formConfig={formConfig} onSubmit={handleSubmit} />
    </div>
  );
}

export default App;

Yup Example Function for Validation

 

// Required field
const isRequired = yup.string().required("This field is required");

// Minimum length
const minLength = yup.string().min(5, "Must be at least 5 characters");

// Maximum length
const maxLength = yup.string().max(10, "Must be 10 characters or fewer");

// Email format
const isEmail = yup.string().email("Must be a valid email");

// Date validation
const isDate = yup.date().typeError("Must be a valid date");

// Number validation
const isNumber = yup.number().typeError("Must be a number");

// Positive number
const isPositive = yup.number().positive("Must be a positive number");

// Integer check
const isInteger = yup.number().integer("Must be an integer");

// URL validation
const isURL = yup.string().url("Must be a valid URL");

// Matches a specific regex pattern (e.g., letters only)
const matchesPattern = yup.string().matches(/^[a-zA-Z]+$/, "Only letters are allowed");

// Less than a specific number
const lessThan = yup.number().lessThan(100, "Must be less than 100");

// Greater than a specific number
const moreThan = yup.number().moreThan(10, "Must be greater than 10");

// Minimum date
const minDate = yup.date().min(new Date(2023, 0, 1), "Date cannot be before 2023");

// Maximum date
const maxDate = yup.date().max(new Date(2023, 11, 31), "Date cannot be after 2023");

// Test for null or undefined
const isDefined = yup.mixed().defined("Field must be defined");

// Custom validation with test method
const customTest = yup.string().test(
  "is-even",
  "Value must be even",
  value => value && parseInt(value) % 2 === 0
);

// Length must be exactly 5
const exactLength = yup.string().length(5, "Must be exactly 5 characters");

// Not one of a set of values
const notOneOf = yup.string().notOneOf(["admin", "superuser"], "Invalid username");

// One of a set of values (enum)
const oneOfEnum = yup.string().oneOf(["apple", "banana", "cherry"], "Invalid fruit");

// Valid JSON format
const isJSON = yup.string().test(
  "is-json",
  "Must be a valid JSON string",
  value => {
    try {
      JSON.parse(value);
      return true;
    } catch (e) {
      return false;
    }
  }
);
 

Contributors