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

fmvalidation

v1.0.1

Published

UI validation library

Downloads

29

Readme

Validation

This library help us to validate the form as well as model.

Prerequisites

You will need jQuery in order to use this library.

npm install jquery

Installing

You can get the library by using following command:

npm install fmvalidation

Example

var layout = [
	selector: '.username',
	rules: {
		required: true,
	},
	message: {
		required: 'Username is required'
	}
]
var validate = new Validation({
	layout: layout
}, $('form'));

Structure of validation with all properties

var layout = [{
	identifier: <string> 
	path: <string>,
	selector: <string>,
	rules:{
		required: <values for validation>,
		<custom_rule>: <function>
	}
	message: {
		required: <string>,
		<custom_rule>: <string>
	}
	getValue: <string/function>
	showError: <function>
	hideError: <function>
	errorContainer: <string>
}]
var validate = new Validation({
	layout: layout
	errorOnSubmit: <boolean>,
	errorOnChange: <boolean>,
	defaultError: <boolean>,
	model: <object>,
	showAllErrors: <function>,
	hideAllErrors: <function>,
	errorContainer: <string>,
}, $('form'));

Uses of Properties

identifier

It will unqiue identifier if you want to validate only the particular selector. ex: validate.validate()

path / selector

We need to specify path or selector. If you need to valdiate form then selector should provided or if you want to validate model the path('test1.0.name') should be provided.

rules

Rules are inbuilt rules or function that validate the form or object path.

messages

Messages are shown when error occurs in validation for rules.

getValue

If we are not able to read value from element from form or object we can return value which will be used for validation

showError/hideError

If we want to show and hide error in our way we can use these.

errorContainer

Display error in specific element.

defaultError

By default its true. If its true, validation will happen when user is typing.

errorOnChange

By default its false. If its true, validation will happen when user change the value. It will overwrite the defaultError.

errorOnSubmit

By default its false. If its true, validation will happen when user call validate or form sumbit. It will overwrite the defaultError.

showAllErrors/hideAllErrors

If we want to show and hide all errors in our way we can use these.

model

If we have model based approach and can't valdaite the form, we can pass an object on which we have to do validation.

Methods

validate()

It will validate and display error if any. It will return true if no validation error occurs. If identifier is present it will valid only that rule.

isValid()

It will only valdiate the form or object but will not through error.

addRule()

It will add rule at runtime.

removeRule()

It will remove rule at runtime.

resetErrors

Reset all errors

Global Method

Validation.addValidation(name, regx/function)

It will add validation rule globally and we can you in our rules -> layout;

Inbuilt Rules

required - true
name - true
number - true
decimal - true
username - true
password - true
email - true
url - true
date - true
equalTo - selector for other element
minLength - length
maxLength - length
rangeLength - [min, max]
minValue - value
maxValue - value
rangeValue - [min, max]
valueEqualTo - string/array
valueNotEqualTo - string/array