isifier
A validation library creator
Table of contents
Summary
We all have seen a thousand validation libraries out there, but there is something they all have in common: they have way, way more tests than your project could ever need. All you need to do is validate strings, and you pull in something that validates social security numbers, canadian zip codes, and IPV6 addresses, which adds excess bloat to your application without any additional benefit.
With isifier
, the library is only as targeted as you need it to be, as all it does is create a namespace for your tests and a method to add to it. It is 440 bytes minified and gzipped.
Usage
; // add common type testsis; console; // trueconsole; // false // or complex validationis; console; // trueconsole; // true // it also adds "all" and "any" convienence methods to test multiple values at onceconsole; // trueconsole; // true
addTest
is.addTest(name: string, validator: function): boolean
Adds a new validator test to the is
object, accessible on all uses of is
from that point on.
Other methods
createInstance
Create a unique instance of isifier
. Useful if you want to avoid collisions with other library applications.
; is; const instance = ; console; // false instance; console; // trueconsole; // false
Browser support
- Chrome (all versions)
- Firefox (all versions)
- Edge (all versions)
- Opera 15+
- IE 9+
- Safari 6+
- iOS 8+
- Android 4+
Development
Standard stuff, clone the repo and npm install
dependencies. The npm scripts available:
build
=> run webpack to build developmentdist
file with NODE_ENV=developmentbuild:minified
=> run webpack to build productiondist
file with NODE_ENV=productiondev
=> run webpack dev server to run example app / playgrounddist
=> runsbuild
andbuild:minified
lint
=> run ESLint against all files in thesrc
folderprepublish
=> runsprepublish:compile
when publishingprepublish:compile
=> runlint
,test:coverage
,transpile:es
,transpile:lib
,dist
test
=> run AVA test functions withNODE_ENV=test
test:coverage
=> runtest
but withnyc
for coverage checkertest:watch
=> runtest
, but with persistent watchertranspile:lib
=> run babel against all files insrc
to create files inlib
transpile:es
=> run babel against all files insrc
to create files ines
, preserving ES2015 modules (forpkg.module
)