UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

37 lines (33 loc) 908 B
/*jshint laxcomma: true, smarttabs: true, node: true*/ 'use strict'; /** * Resource Field for dealing with boolean values * @module tastypie/fields/boolean * @author Eric Satterwhite * @since 0.5.0 * @requires tastypie/lib/class * @requires tastypie/lib/fields/api */ var typecast = require( 'mout/string/typecast' ) , Class = require( '../class' ) , ApiField = require('./api') , BooleanField ; /** * @constructor * @alias module:tastypie/fields/boolean * @extends module:tastypie/fields/api */ exports.BooleanField = BooleanField = new Class({ inherits: ApiField ,options:{ help:'Forces all values to either true of false' } ,convert: function convert( value ){ return !!( typeof value === 'string' ? typecast( value ) : value ) ; } ,type: function type(){ return 'boolean'; } }); module.exports = BooleanField;