Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

28 lines (19 sloc) 0.575 kB

Coerce

Simple chaining style type validator inspired by Waleed's Purify python library

Features

  • light-weight
  • can be used via node or browser
  • geared to make code more readable & reusable

Usage

If you use node:

var c = require('coerce');
var easyInt = c().strip().int();
easyInt.coerce("   123   ") ---> 123
easyInt.default(456).coerce("asdf") ---> 456

If you use a web browser:

<script src="coerce.js"></script>
<script>
  var c = coerce().strip().int();
  var myInteger = c.coerce("   123   ");
</script>
Jump to Line
Something went wrong with that request. Please try again.