lib/swig.js
function validateOptions(options) {
  if (!options) {
    return;
  }

  utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) {
    if (!options.hasOwnProperty(key)) {
      return;
    }
    if (!utils.isArray(options[key]) || options[key].length !== 2) {
      throw new Error('Option "' + key + '" must be an array containing 2 different control strings.');
    }
    if (options[key][0] === options[key][1]) {
      throw new Error('Option "' + key + '" open and close controls must not be the same.');
    }
    utils.each(options[key], function (a, i) {
      if (a.length < 2) {
        throw new Error('Option "' + key + '" ' + ((i) ? 'open ' : 'close ') + 'control must be at least 2 characters. Saw "' + a + '" instead.');
      }
    });
  });

  if (options.hasOwnProperty('cache')) {
    if (options.cache && options.cache !== 'memory') {
      if (!options.cache.get || !options.cache.set) {
        throw new Error('Invalid cache option ' + JSON.stringify(options.cache) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.');
      }
    }
  }
  if (options.hasOwnProperty('loader')) {
    if (options.loader) {
      if (!options.loader.load || !options.loader.resolve) {
        throw new Error('Invalid loader option ' + JSON.stringify(options.loader) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.');
      }
    }
  }

}
function validateOptions(options) {
  if (!options) {
    return;
  }

  utils.each(['varControls', 'tagControls', 'cmtControls'], function (key) {
    if (!options.hasOwnProperty(key)) {
      return;
    }
    if (!utils.isArray(options[key]) || options[key].length !== 2) {
      throw new Error('Option "' + key + '" must be an array containing 2 different control strings.');
    }
    if (options[key][0] === options[key][1]) {
      throw new Error('Option "' + key + '" open and close controls must not be the same.');
    }
    utils.each(options[key], function (a, i) {
      if (a.length < 2) {
        throw new Error('Option "' + key + '" ' + ((i) ? 'open ' : 'close ') + 'control must be at least 2 characters. Saw "' + a + '" instead.');
      }
    });
  });

  if (options.hasOwnProperty('cache')) {
    if (options.cache && options.cache !== 'memory') {
      if (!options.cache.get || !options.cache.set) {
        throw new Error('Invalid cache option ' + JSON.stringify(options.cache) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.');
      }
    }
  }
  if (options.hasOwnProperty('loader')) {
    if (options.loader) {
      if (!options.loader.load || !options.loader.resolve) {
        throw new Error('Invalid loader option ' + JSON.stringify(options.loader) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.');
      }
    }
  }

}
function validateOptions ( options ) { if ( ! options ) { return ; } utils . each ( [ 'varControls' , 'tagControls' , 'cmtControls' ] , function ( key ) { if ( ! options . hasOwnProperty ( key ) ) { return ; } if ( ! utils . isArray ( options [ key ] ) || options [ key ] . length !== 2 ) { throw new Error ( 'Option "' + key + '" must be an array containing 2 different control strings.' ) ; } if ( options [ key ] [ 0 ] === options [ key ] [ 1 ] ) { throw new Error ( 'Option "' + key + '" open and close controls must not be the same.' ) ; } utils . each ( options [ key ] , function ( a , i ) { if ( a . length < 2 ) { throw new Error ( 'Option "' + key + '" ' + ( ( i ) ? 'open ' : 'close ' ) + 'control must be at least 2 characters. Saw "' + a + '" instead.' ) ; } } ) ; } ) ; if ( options . hasOwnProperty ( 'cache' ) ) { if ( options . cache && options . cache !== 'memory' ) { if ( ! options . cache . get || ! options . cache . set ) { throw new Error ( 'Invalid cache option ' + JSON . stringify ( options . cache ) + ' found. Expected "memory" or { get: function (key) { ... }, set: function (key, value) { ... } }.' ) ; } } } if ( options . hasOwnProperty ( 'loader' ) ) { if ( options . loader ) { if ( ! options . loader . load || ! options . loader . resolve ) { throw new Error ( 'Invalid loader option ' + JSON . stringify ( options . loader ) + ' found. Expected { load: function (pathname, cb) { ... }, resolve: function (to, from) { ... } }.' ) ; } } } }
Validate the Swig options object.
@param  {?SwigOpts} options Swig options object.
@return {undefined}      This method will throw errors if anything is wrong.
@private
Validate the Swig options object .