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 🙏

© 2024 – Pkg Stats / Ryan Hefner

formoose

v2.0.2

Published

Schema-based run time validation engine, made to integrate back and front-end validations using Mongoose like schemas.

Downloads

27

Readme

Formoose

Node.js CI Node.js CI GitHub license npm version PRs Welcome

Formoose is a runtime validation engine, based on Mongoose's 🐻 schemas.

Meant to integrate React Controled Forms with back-end APIs using MongoDB.

It IS NOT intended to do magic and generate automatically HTML forms, fields, nor styles, or React components for you.

It DOES provide an easy way to parse and validate the same Mongoose Schema using React & Hooks, integrating back and front-end validations in the same source of truth.

IMPORTANT Note: 🐻 Mongoose lib isn't required at the front-side at all, you can use any schemas following these guide lines, and validate them using Mongoose built in validators at the back-end side.

Provides:

  • Fast sync/async validations for the whole schema.
  • Validation for single fields
  • Tools to set up errors on specific fields, to clean, deal with changes etc.
  • Friendly and consistent error messages with internationalization support using react-i18next.
  • Real time validation in forms
  • Custom validations using simple Java Script functions, which allows you to validate whatever you want like Regexes, API based validations, custom logic etc.

🚀 Getting started:

Basic example:

import React, { useState } from 'react';
import { useFormoose } from 'formoose';

const schema = () => ({
  name: {
    max: 50,
    required: true,
    type: String
  }
});

function FormooseFormExample() {
  const {
    formData,
    validateAllFieldsSync,
    setProps
  } = useFormoose(schema(), t);

  const handleSubmit = async e => {
    e.preventDefault();

    let formIsValid;

    try {
      formIsValid = await validateAllFieldsSync();
    } catch (error) {
      console.error(error);
    }

    if (formIsValid) {
      alert('We are good to go!');
    } else {
      alert('oops, something went wrong.');
    }
  };

  return(
    <form onSubmit={handleSubmit}>
      <input type="text" placeholder="Name" {...setProps('name')} />
      <label htmlFor="name">{t(formData.name.message)}</label>
      <button type="submit">Submit</button>
    </form>
  );

}

export default FormooseFormExample;

Examples available at https://github.com/romulobordezani/formoose-example or at this sand box

Contributing:

Fell free to fork and submit changes and improvements, also please let me know if you find any issues.

Running the core project

Install dependencies.

yarn
yarn dev

Type Script will compile to dist folder, use yarn link.

Go to the example repository and run:

yarn link formoose

Run yarn start and the browser should open with some examples using your local Formoose's code. Now you can test and debug your changes.

Looking for something else?

So, you reached the end of these documentation and still thinks that Formoose is not for you?

No problem! If you aren't interested in using Mogoose schemas to control your forms, or i18n to provide instant translations to your forms, or in the Type Script definitions to provide you a great Development Experience - in a really small package.

Probably you are looking for something else like:

And to use it with react-hook-form.com or formik

Hope it helps 🍀.