UNPKG

fashion-model

Version:

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

26 lines (21 loc) 502 B
module.exports = require('./Model').extend({ typeName: 'integer', wrap: false, coerce: function (value, options) { if (options.strict) { // strict mode if (value != null && (value.constructor !== Number)) { this.coercionError(value, options); } return value; } if (value == null) { return value; } const number = parseInt(value, 10); if (isNaN(number)) { this.coercionError(value, options); } return number; } });