Code coverage report for src/validate.js

Statements: 94.44% (17 / 18)      Branches: 83.33% (10 / 12)      Functions: 100% (4 / 4)      Lines: 87.5% (7 / 8)      Ignored: 1 branch     

All files » src/ » validate.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32        1                               1 23 253 222     31          
import forEach from 'lodash.foreach';
import { is } from './utility';
import { format } from 'util';
 
const rules = {
  // hook
  extensions:         'array',
  preprocessCss:      'function',
  processCss:         'function',
  to:                 'string',
  // plugins
  append:             'array',
  prepend:            'array',
  use:                'array',
  createImportedName: 'function',
  generateScopedName: 'function|string',
  mode:               'string',
  rootDir:            'string',
};
 
export default function validate(options = {}) {
  forEach(rules, (types, rule) => {
    if (!options[rule]) {
      return;
    }
 
    Iif (!types.split('|').some(type => is(type, options[rule]))) {
      throw new Error(format('should specify %s for the %s', types, rule));
    };
  });
}