dist/LatticeFactory.js
function validateTemplate(template) {
      var hide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var results = new ValidationResults();

      var indent = function indent(string) {
        var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
        var space = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
        return string.split('\n').map(function (s) {
          return s.trim().replace(/(^)/gm, "$1".concat(space.repeat(count)));
        }).join('\n');
      };

      if (typeof template.name === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject2())));
      }

      if (!(0, _neTypes.extendsFrom)(template.name, String)) {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject3())));
      }

      if (typeof template.schema === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject4())));
      }

      if (!(0, _neTypes.extendsFrom)(template.schema, String)) {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject5())));
      }

      if (!(0, _neTypes.extendsFrom)(template.resolvers, Object) // Supports 95% of objects
      || (0, _typeof2.default)(template.resolvers) !== 'object' // Supports Object.create(null)
      ) {
          results.errors.push(new Error((0, _neTagFns.customDedent)({
            dropLowest: true
          })(_templateObject6())));
        }

      if (typeof template.docs === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject7())));
      }

      if (!(0, _neTypes.extendsFrom)(template.docs, Object) // Supports 95% of objects
      || (0, _typeof2.default)(template.docs) !== 'object' // Supports Object.create(null)
      ) {
          var dr = '\x1b[31m',
              br = '\x1b[91m';
          var b1 = '\x1b[1m',
              b0 = '\x1b[22m';
          var bb = '\x1b[90m';
          var dg = '\x1b[37m',
              bg = '\x1b[97m';
          var a0 = '\x1b[0m';
          var gr = '\x1b[32m',
              bgr = '\x1b[92m';
          results.errors.push(new Error((0, _neTagFns.customDedent)({
            dropLowest: true
          })(_templateObject8(), bb, dg, b1, b0, gr, dg, b1, b0, b1, b0, gr, dg, gr, dg, gr, dg, b1, b0, gr, dg, b1, b0, gr, dg)));
        }

      if (!results.valid) {
        var errorStrings = [];
        var _iteratorNormalCompletion = true;
        var _didIteratorError = false;
        var _iteratorError = undefined;

        try {
          for (var _iterator = results.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
            var _error = _step.value;
            var message = _error.message,
                stack = _error.stack;
            stack = stack.trim().split('\n').splice(message.split('\n').length).map(function (s) {
              return s.trim();
            }).join('\n');
            message = message.replace(/(Error:\s)/, '$1\n').trim();
            errorStrings.push("\x1B[31;1m".concat(message, "\x1B[0m\n") + indent(stack));
          }
        } catch (err) {
          _didIteratorError = true;
          _iteratorError = err;
        } finally {
          try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
              _iterator.return();
            }
          } finally {
            if (_didIteratorError) {
              throw _iteratorError;
            }
          }
        }

        var error = new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject9()).replace(/@template/, indent(_i(template))).replace(/@errors/, errorStrings.join('\n\n')));
        error.stack = error.message;
        error.message = '';
        if (!hide) throw error;
      }

      return results;
    }
function validateTemplate(template) {
      var hide = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
      var results = new ValidationResults();

      var indent = function indent(string) {
        var count = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4;
        var space = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ' ';
        return string.split('\n').map(function (s) {
          return s.trim().replace(/(^)/gm, "$1".concat(space.repeat(count)));
        }).join('\n');
      };

      if (typeof template.name === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject2())));
      }

      if (!(0, _neTypes.extendsFrom)(template.name, String)) {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject3())));
      }

      if (typeof template.schema === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject4())));
      }

      if (!(0, _neTypes.extendsFrom)(template.schema, String)) {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject5())));
      }

      if (!(0, _neTypes.extendsFrom)(template.resolvers, Object) // Supports 95% of objects
      || (0, _typeof2.default)(template.resolvers) !== 'object' // Supports Object.create(null)
      ) {
          results.errors.push(new Error((0, _neTagFns.customDedent)({
            dropLowest: true
          })(_templateObject6())));
        }

      if (typeof template.docs === 'undefined') {
        results.errors.push(new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject7())));
      }

      if (!(0, _neTypes.extendsFrom)(template.docs, Object) // Supports 95% of objects
      || (0, _typeof2.default)(template.docs) !== 'object' // Supports Object.create(null)
      ) {
          var dr = '\x1b[31m',
              br = '\x1b[91m';
          var b1 = '\x1b[1m',
              b0 = '\x1b[22m';
          var bb = '\x1b[90m';
          var dg = '\x1b[37m',
              bg = '\x1b[97m';
          var a0 = '\x1b[0m';
          var gr = '\x1b[32m',
              bgr = '\x1b[92m';
          results.errors.push(new Error((0, _neTagFns.customDedent)({
            dropLowest: true
          })(_templateObject8(), bb, dg, b1, b0, gr, dg, b1, b0, b1, b0, gr, dg, gr, dg, gr, dg, b1, b0, gr, dg, b1, b0, gr, dg)));
        }

      if (!results.valid) {
        var errorStrings = [];
        var _iteratorNormalCompletion = true;
        var _didIteratorError = false;
        var _iteratorError = undefined;

        try {
          for (var _iterator = results.errors[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
            var _error = _step.value;
            var message = _error.message,
                stack = _error.stack;
            stack = stack.trim().split('\n').splice(message.split('\n').length).map(function (s) {
              return s.trim();
            }).join('\n');
            message = message.replace(/(Error:\s)/, '$1\n').trim();
            errorStrings.push("\x1B[31;1m".concat(message, "\x1B[0m\n") + indent(stack));
          }
        } catch (err) {
          _didIteratorError = true;
          _iteratorError = err;
        } finally {
          try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
              _iterator.return();
            }
          } finally {
            if (_didIteratorError) {
              throw _iteratorError;
            }
          }
        }

        var error = new Error((0, _neTagFns.customDedent)({
          dropLowest: true
        })(_templateObject9()).replace(/@template/, indent(_i(template))).replace(/@errors/, errorStrings.join('\n\n')));
        error.stack = error.message;
        error.message = '';
        if (!hide) throw error;
      }

      return results;
    }
function validateTemplate ( template ) { var hide = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : false ; var results = new ValidationResults ( ) ; var indent = function indent ( string ) { var count = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 4 ; var space = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : ' ' ; return string . split ( '\n' ) . map ( function ( s ) { return s . trim ( ) . replace ( / (^) / gm , "$1" . concat ( space . repeat ( count ) ) ) ; } ) . join ( '\n' ) ; } ; if ( typeof template . name === 'undefined' ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject2 ( ) ) ) ) ; } if ( ! ( 0 , _neTypes . extendsFrom ) ( template . name , String ) ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject3 ( ) ) ) ) ; } if ( typeof template . schema === 'undefined' ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject4 ( ) ) ) ) ; } if ( ! ( 0 , _neTypes . extendsFrom ) ( template . schema , String ) ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject5 ( ) ) ) ) ; } if ( ! ( 0 , _neTypes . extendsFrom ) ( template . resolvers , Object ) // Supports 95% of objects || ( 0 , _typeof2 . default ) ( template . resolvers ) !== 'object' // Supports Object.create(null) ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject6 ( ) ) ) ) ; } if ( typeof template . docs === 'undefined' ) { results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject7 ( ) ) ) ) ; } if ( ! ( 0 , _neTypes . extendsFrom ) ( template . docs , Object ) // Supports 95% of objects || ( 0 , _typeof2 . default ) ( template . docs ) !== 'object' // Supports Object.create(null) ) { var dr = '\x1b[31m' , br = '\x1b[91m' ; var b1 = '\x1b[1m' , b0 = '\x1b[22m' ; var bb = '\x1b[90m' ; var dg = '\x1b[37m' , bg = '\x1b[97m' ; var a0 = '\x1b[0m' ; var gr = '\x1b[32m' , bgr = '\x1b[92m' ; results . errors . push ( new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject8 ( ) , bb , dg , b1 , b0 , gr , dg , b1 , b0 , b1 , b0 , gr , dg , gr , dg , gr , dg , b1 , b0 , gr , dg , b1 , b0 , gr , dg ) ) ) ; } if ( ! results . valid ) { var errorStrings = [ ] ; var _iteratorNormalCompletion = true ; var _didIteratorError = false ; var _iteratorError = undefined ; try { for ( var _iterator = results . errors [ Symbol . iterator ] ( ) , _step ; ! ( _iteratorNormalCompletion = ( _step = _iterator . next ( ) ) . done ) ; _iteratorNormalCompletion = true ) { var _error = _step . value ; var message = _error . message , stack = _error . stack ; stack = stack . trim ( ) . split ( '\n' ) . splice ( message . split ( '\n' ) . length ) . map ( function ( s ) { return s . trim ( ) ; } ) . join ( '\n' ) ; message = message . replace ( / (Error:\s) / , '$1\n' ) . trim ( ) ; errorStrings . push ( "\x1B[31;1m" . concat ( message , "\x1B[0m\n" ) + indent ( stack ) ) ; } } catch ( err ) { _didIteratorError = true ; _iteratorError = err ; } finally { try { if ( ! _iteratorNormalCompletion && _iterator . return != null ) { _iterator . return ( ) ; } } finally { if ( _didIteratorError ) { throw _iteratorError ; } } } var error = new Error ( ( 0 , _neTagFns . customDedent ) ( { dropLowest : true } ) ( _templateObject9 ( ) ) . replace ( / @template / , indent ( _i ( template ) ) ) . replace ( / @errors / , errorStrings . join ( '\n\n' ) ) ) ; error . stack = error . message ; error . message = '' ; if ( ! hide ) throw error ; } return results ; }
Walks through a supplied template object and collects errors with its
format before bubbling up an exception if any part of it fails to
pass muster. The exception can be prevented from throwing if hide is set
to true

@param {Object} template an object to be parsed for construction via the
Lattice Factory
@param {boolean} hide if true, an invalid template will NOT throw errors
@return {ValidationResults} a `ValidationResults` object containing the
collected errors and a `valid` that is dynamically calculated.
Walks through a supplied template object and collects errors with its format before bubbling up an exception if any part of it fails to pass muster . The exception can be prevented from throwing if hide is set to true