We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5d830cd commit 2a8c9d6Copy full SHA for 2a8c9d6
1 file changed
src/validate.js
@@ -1 +1,31 @@
1
-export default function validate() {}
+import forEach from 'lodash.foreach';
2
+import { is } from './utility';
3
+import { format } from 'util';
4
+
5
+const rules = {
6
+ // hook
7
+ extensions: 'array',
8
+ preprocessCss: 'function',
9
+ processCss: 'function',
10
+ to: 'string',
11
+ // plugins
12
+ append: 'array',
13
+ prepend: 'array',
14
+ use: 'array',
15
+ createImportedName: 'function',
16
+ generateScopedName: 'function|string',
17
+ mode: 'string',
18
+ rootDir: 'string',
19
+};
20
21
+export default function validate(options = {}) {
22
+ forEach(rules, (types, rule) => {
23
+ if (!options[rule]) {
24
+ return;
25
+ }
26
27
+ if (!types.split('|').some(type => is(type, options[rule]))) {
28
+ throw new Error(format('should specify %s for the %s', types, rule));
29
+ };
30
+ });
31
+}
0 commit comments