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

formations

v1.0.13

Published

A validations library in es6 javascript.

Downloads

7

Readme

Formations Build Status

A simple and complete server-side and client-side validations library in ES6 JavaScript compiled with Babel.

Influence

Play Framework 2.x.x allows easily defined and testable form validations.

Features

  • Easily transformable constraints i.e. number.min(10).max(56) or text.matches("[A-Za-z]")
  • Makes no assumption of client/server
  • Validates JSON forms
  • "true" and true will both validate as booleans (same with other validation types)
  • Validate on your own "types" by writing text constraints
  • Cross-form validation (lame example for now)

Install

To install, just run: npm install --save formations

Usage

Here is an example validation for a register form.

import * as formations from 'formations';
import {text, number, email} from 'formations/lib/Validations';
 
var form = formations.createForm(document, ['name', 'email', 'password', 'age']);
 
var registerValidation = {
  name: text.minLength(2, "You need a bigger name.").maxLength(32, "Your name must be less than 33 characters.."),
  password: text.bounds(8, 64, "Your password must be between 8 and 64 characters."),
  email: email.maxLength(64, "Use a smaller e-mail, please!"),
  age: number.min(13, "You must be at least 13 years old.").max(80, "You're too old for this, dude."),
  correctAge: boolean.cross('age', number.bounds(13, 80), boolean.equals(true), "You have to say if you're the correct age.")
};
 
var results = formations.validateForm(form, registerValidation);
 
if(results.passed())
  console.log("You're good to go!");
else
  console.log("fail");

List of validations

  • number
  • text
  • boolean
  • email

If there is a validation "type" we don't have, just write a text validation and write the needed constraints.

Contributing

Open pull requests and issues whenever needed!