Skip to content

Instantly share code, notes, and snippets.

@lorenzoongithub
Created July 1, 2015 19:46
Show Gist options
  • Save lorenzoongithub/89733e1dc8e1a02c34f2 to your computer and use it in GitHub Desktop.
Save lorenzoongithub/89733e1dc8e1a02c34f2 to your computer and use it in GitHub Desktop.
xtypejs
//
// http://xtype.js.org
// Elegant, highly efficient data validation for JavaScript
//
load('https://rawgit.com/lucono/xtypejs/master/xtype.js');
x = xtype.isSingleCharString('g')
if (x !== true) throw '';
x = xtype.isNonEmptyObject({foo: 'bar'})
if (x !== true) throw '';
x = xtype.isSingleElemArray(['foo'])
if (x !== true) throw '';
x = xtype.isFloat(2.50);
if (x !== true) throw '';
x = xtype.isPositiveNumber(-2.5);
if (x) throw '';
x = xtype.isNan(5 / 'hi')
if (x !== true) throw '';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment