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

form-formatters

v1.2.6

Published

Formatters and masks for validating and manipulating user input.

Downloads

23

Readme

Form Formatters

CircleCI

Formatters and masks for validating and manipulating user input.

Formatters take user input in an object and return an object representing user data, parsed data, and errors. For example if the user entered " 1112223333 " into a currency field. The response would be:

{
  errors: [],
  formatted: "$1,112,223,333.00",
  parsed: 1112223333,
  valid: true
}

Entering "abc" into a currency field would result in:

{
  error: ["FormFormatters.required"],
  formatted: "abc",
  parsed: "abc",
  valid: false
}

You might be thinking, but it's a number field how come the result has letters in it? Well the formatters job is to format the text and respond with whether it is valid. The masks job is to mask out values like letters from currency inputs. The mask should run before the formatter.

Data going into the formatters is structured the same going in as coming out that way they are chainable.

Converters take a parsed value (from the api) and convert them into a form usable value.

The mask will return in the the same format as the entry. In other words, it will not return in a complex object.

Error Messaging

This library is designed for use with a translation tool. It will respond with unique keys representing error text. You could use Simple Translator library for multi lingual support on error messages.

Formatters

  • ArrayFormatter
  • CurrencyFormatter
  • DateFormatter
  • EmailFormatter
  • HexFormatter
  • NameFormatter
  • NumberFormatter
  • PercentFormatter
  • PhoneFormatter
  • RgbFormatter
  • SsnLastFourFormatter
  • StringFormatter
  • TimeFormatter

Masks

  • ArrayMask
  • CurrencyMask
  • DecimalMask
  • EmailMask
  • HexMask
  • NumberMask
  • PercentMask
  • PhoneMask
  • SsnMask
  • SsnLastFourMask
  • StringMask
  • TimeMask
  • WholeNumberMask

Converters

  • DateConverter

Releases

v1.0.3

Fixing formatters to work with same in same out object approach.

Added date converter.

v1.0.2

Added Array formatter and Array Mask

v1.0.1

Added Number mask

v0.4.1

Hex formatter now includes a # symbol at the beginning of the string.

v0.4.0

  • Add credit card formatter