'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = validateType;

var _validationError;

function _load_validationError() {
  return _validationError = _interopRequireDefault(require('../error/validation-error'));
}

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

function validateType(message, value, fieldName, expectedType) {
  var type = typeof value;
  if ((expectedType === 'array' || expectedType === 'object') && Array.isArray(value)) type = 'array';
  if (type !== expectedType) {
    throw new (_validationError || _load_validationError()).default(`${message}, expected ${fieldName} to be ${expectedType}, got ${type}`);
  }
}