'use strict';

exports.__esModule = true;
exports.default = validate;

var _lodash = require('lodash.isnumber');

var _lodash2 = _interopRequireDefault(_lodash);

var _lodash3 = require('lodash.tonumber');

var _lodash4 = _interopRequireDefault(_lodash3);

var _utils = require('./utils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function validate(value, context) {
  var _ref = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];

  var _ref$errorMessage = _ref.errorMessage;
  var errorMessage = _ref$errorMessage === undefined ? false : _ref$errorMessage;

  if ((0, _utils.isEmpty)(value)) return true;

  var number = (0, _lodash4.default)(value);

  return (0, _lodash2.default)(number) && !isNaN(number) || errorMessage;
}