lib/index.js
function _validateMitto(mittoObject) {
  if (!mittoObject) {
    return null;
  }

  if (!mittoObject.hasOwnProperty("name")) {
    throw new Error("\"name\" property is missing from your .mitto and is required.");
  }

  if (mittoObject.hasOwnProperty("required")) {
    for (var key in mittoObject.required) {
      if (mittoObject.required[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.required[key].type) === -1) {
          throw new Error(mittoObject.required[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's required parameter \"" + key + "\"");
      }

      if (mittoObject.required[key].hasOwnProperty("description") && typeof mittoObject.required[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's required parameter " + key + " must be of type \"string\"");
      }
    }
  }

  if (mittoObject.hasOwnProperty("optional")) {
    for (var key in mittoObject.optional) {
      if (mittoObject.optional[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.optional[key].type) === -1) {
          throw new Error(mittoObject.optional[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's optional parameter " + key);
      }

      if (mittoObject.optional[key].hasOwnProperty("description") && typeof mittoObject.optional[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's optional parameter " + key + " must be of type \"string\"");
      }

      if (mittoObject.optional[key].hasOwnProperty("default") && _typeof(mittoObject.optional[key].default) !== mittoObject.optional[key].type) {
        throw new Error("\"default\" property of your .mitto's optional parameter " + key + " must be a " + mittoObject.optional[key].type + ", as specified by \"type\"");
      } else if (mittoObject.optional[key].hasOwnProperty("default")) {
        mittoObject.hasDefault = true;
      }
    }
  }

  return mittoObject;
}
function _validateMitto(mittoObject) {
  if (!mittoObject) {
    return null;
  }

  if (!mittoObject.hasOwnProperty("name")) {
    throw new Error("\"name\" property is missing from your .mitto and is required.");
  }

  if (mittoObject.hasOwnProperty("required")) {
    for (var key in mittoObject.required) {
      if (mittoObject.required[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.required[key].type) === -1) {
          throw new Error(mittoObject.required[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's required parameter \"" + key + "\"");
      }

      if (mittoObject.required[key].hasOwnProperty("description") && typeof mittoObject.required[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's required parameter " + key + " must be of type \"string\"");
      }
    }
  }

  if (mittoObject.hasOwnProperty("optional")) {
    for (var key in mittoObject.optional) {
      if (mittoObject.optional[key].hasOwnProperty("type")) {
        if (DATA_TYPES.indexOf(mittoObject.optional[key].type) === -1) {
          throw new Error(mittoObject.optional[key].type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"");
        }
      } else {
        throw new Error("\"type\" property is missing from your .mitto's optional parameter " + key);
      }

      if (mittoObject.optional[key].hasOwnProperty("description") && typeof mittoObject.optional[key].description !== "string") {
        throw new Error("\"description\" property of your .mitto's optional parameter " + key + " must be of type \"string\"");
      }

      if (mittoObject.optional[key].hasOwnProperty("default") && _typeof(mittoObject.optional[key].default) !== mittoObject.optional[key].type) {
        throw new Error("\"default\" property of your .mitto's optional parameter " + key + " must be a " + mittoObject.optional[key].type + ", as specified by \"type\"");
      } else if (mittoObject.optional[key].hasOwnProperty("default")) {
        mittoObject.hasDefault = true;
      }
    }
  }

  return mittoObject;
}
function _validateMitto ( mittoObject ) { if ( ! mittoObject ) { return null ; } if ( ! mittoObject . hasOwnProperty ( "name" ) ) { throw new Error ( "\"name\" property is missing from your .mitto and is required." ) ; } if ( mittoObject . hasOwnProperty ( "required" ) ) { for ( var key in mittoObject . required ) { if ( mittoObject . required [ key ] . hasOwnProperty ( "type" ) ) { if ( DATA_TYPES . indexOf ( mittoObject . required [ key ] . type ) === - 1 ) { throw new Error ( mittoObject . required [ key ] . type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"" ) ; } } else { throw new Error ( "\"type\" property is missing from your .mitto's required parameter \"" + key + "\"" ) ; } if ( mittoObject . required [ key ] . hasOwnProperty ( "description" ) && typeof mittoObject . required [ key ] . description !== "string" ) { throw new Error ( "\"description\" property of your .mitto's required parameter " + key + " must be of type \"string\"" ) ; } } } if ( mittoObject . hasOwnProperty ( "optional" ) ) { for ( var key in mittoObject . optional ) { if ( mittoObject . optional [ key ] . hasOwnProperty ( "type" ) ) { if ( DATA_TYPES . indexOf ( mittoObject . optional [ key ] . type ) === - 1 ) { throw new Error ( mittoObject . optional [ key ] . type + " is not a valid data type. Expected: \"undefined\", \"object\", \"boolean\", \"number\", \"string\", \"symbol\", or \"function\"" ) ; } } else { throw new Error ( "\"type\" property is missing from your .mitto's optional parameter " + key ) ; } if ( mittoObject . optional [ key ] . hasOwnProperty ( "description" ) && typeof mittoObject . optional [ key ] . description !== "string" ) { throw new Error ( "\"description\" property of your .mitto's optional parameter " + key + " must be of type \"string\"" ) ; } if ( mittoObject . optional [ key ] . hasOwnProperty ( "default" ) && _typeof ( mittoObject . optional [ key ] . default ) !== mittoObject . optional [ key ] . type ) { throw new Error ( "\"default\" property of your .mitto's optional parameter " + key + " must be a " + mittoObject . optional [ key ] . type + ", as specified by \"type\"" ) ; } else if ( mittoObject . optional [ key ] . hasOwnProperty ( "default" ) ) { mittoObject . hasDefault = true ; } } } return mittoObject ; }
Validate .mitto object handed off to function to ensure it is syntatical correct
Validate . mitto object handed off to function to ensure it is syntatical correct