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

dataentry

v2.0.5

Published

Forms validation library that implements Promise based validation of fields and forms, automatic decoration of fields, localized error messages.

Downloads

2

Readme

DataEntry

Forms validation library that implements Promise based validation of fields and forms, automatic decoration of fields, localized error messages. The library has no dependency on other libraries and can be integrated with frameworks such as React, Vue.js, Aurelia, Knockout, Angular, etc.

Objectives

The objectives of the DataEntry library are:

  • to enable the implementation of application-wide validation strategy: centralizing the logic that displays error messages, marks fields in valid or invalid state, and applies validation and formatting rules
  • to simplify the implementation of fields validation in new applications
  • to simplify the definition of asynchronous validation rules (for example, rules involving AJAX requests)
  • to provide a simple way to define new validation and formatting rules

Features

  • ES6 source code
  • Unit tested source code
  • Promise based validation of fields and forms
  • automatic decoration of fields (valid state, invalid state, neutral)
  • logic to define validation rules
  • logic to define formatting rules
  • logic to apply pre-formatting rules (formatting to be applied upon field focus)
  • logic to define constraints (disallow certain inputs, e.g. only positive integer values, only letters, .etc)
  • support for validation triggers between fields
  • good documentation, in GitHub wiki
  • raised exceptions include a link to GitHub wiki, with instructions on how they can be resolved

What DataEntry is not

DataEntry is not a templating engine. It doesn't create HTML forms, nor populates the values of HTML input elements with values read from objects. DataEntry is only concerned with validation, which can be of objects in memory, or HTML elements. In the latter case, whether the HTML of a form is generated using a server side engine, or the templating engine of client side libraries or frameworks, DataEntry can be used to validate the values of these forms. The only exception is formatting of values inside input fields: DataEntry has built-in features to automatically format values after successful validation (this feature can be turned off as desired), which is a simple case to handle.

Design

The library is designed to clearly separate functions that do business logic from classes that read / write values and mark fields as valid or invalid. See Core classes and design for more information.

Validation schema

In DataEntry, the validation of a group of fields is a promise, composed of validation chains (one for each field defined in the dataentry schema object). Each validation chain is a promise that completes when either the first validation rule fails (resolved with error result or rejected), or all validation rules succeed. This way, every field can have asynchronous methods as part of their validation and all errors are populated at once (the first error for each field). If AJAX requests are necessary to validate certain fields, they can and should be executed after synchronous validation that may happen on the client side, to avoid AJAX requests for a value that it's already known to be invalid.

Validation and chains

Use downloading distribution files

DataEntry library can be used downloading and using distribution files, in distribution folder.

<script src="dataentry.js"></script>

Install using npm

DataEntry library can be installed using npm.

npm install dataentry

Modules can then be imported using CommonJS syntax:

var DataEntry = require("dataentry")
var DataEntryDom = require("dataentry/dom")
// var DataEntryContext = require("dataentry/context")

Or ES6 import syntax:

import DataEntry from "dataentry"
import DataEntryDom from "dataentry/dom"

// example of configuration to use built-int methods for DOM manipulation:
DataEntry.configure({
  marker: DataEntryDom.DomMarker,
  harvester: DataEntryDom.DomHarvester,
  binder: DataEntryDom.DomBinder
})

Example using built-in methods completely abstracted from DOM manipulation:

import DataEntry from "dataentry"
import DataEntryContext from "dataentry/context"

// example of configuration to use built-int methods without DOM manipulation:
DataEntry.configure({
  marker: DataEntryContext.ContextMarker,
  harvester: DataEntryContext.ContextHarvester
})

For more information

Refer to the rich documentation in GitHub wiki.