UNPKG

hhurley

Version:

Tool to find lost security patches for Linux distributions.

38 lines (25 loc) 994 B
/* Copyright IBM Research Emergent Solutions Jesús Pérez <jesusprubio@gmail.com> This code may only be used under the MIT license found at https://opensource.org/licenses/MIT. */ // Public methods: // - Receive a string // - Should throw an error if not passing the check // - The error must include hints about a correct input 'use strict'; const utils = require('./utils'); const errMsgs = require('./errMsgs').parsers; // const dbg = utils.dbg(__filename); module.exports.natural = (value) => { if (utils.validator.isInt(value.toString(), { gt: -1 })) { return parseInt(value, 10); } throw new Error(errMsgs.natural); }; // module.exports.bool = (value) => { // // Passed as booleans and "validator"" always needs strings. // // Could come as a boolean or as a string. // const finalValue = value.toString(); // if (utils.validator.isBoolean(finalValue)) { return utils.validator.toBoolean(finalValue); } // throw new Error(errMsgs.bool); // };