UNPKG

fashion-model

Version:

JavaScript library for defining types and their properties with support for wrapping/unwrapping and serialization/deserialization.

22 lines (19 loc) 469 B
module.exports = require('./Model').extend({ typeName: 'boolean', wrap: false, coerce: function (value, options) { if (options.strict) { // strict mode if (value != null && (value.constructor !== Boolean)) { this.coercionError(value, options); } return value; } if (value == null) { return value; } else if (value.constructor === String) { return (value === 'true'); } return !!value; } });