@@ -47,7 +47,7 @@ npm install schema-utils
47
47
48
48
``` js
49
49
import schema from ' ./path/to/schema.json' ;
50
- import validate from ' schema-utils' ;
50
+ import { validate } from ' schema-utils' ;
51
51
52
52
const options = { option: true };
53
53
const configuration = { name: ' Loader Name/Plugin Name/Name' };
@@ -83,13 +83,12 @@ Type: `Object`
83
83
Object with options.
84
84
85
85
``` js
86
- validate (
87
- schema,
88
- {
89
- name: 123 ,
90
- },
91
- { name: ' MyPlugin' }
92
- );
86
+ import schema from ' ./path/to/schema.json' ;
87
+ import { validate } from ' schema-utils' ;
88
+
89
+ const options = { foo: ' bar' };
90
+
91
+ validate (schema, { name: 123 }, { name: ' MyPlugin' });
93
92
```
94
93
95
94
### ` configuration `
@@ -124,6 +123,11 @@ Default: `"Object"`
124
123
Allow to setup name in validation errors.
125
124
126
125
``` js
126
+ import schema from ' ./path/to/schema.json' ;
127
+ import { validate } from ' schema-utils' ;
128
+
129
+ const options = { foo: ' bar' };
130
+
127
131
validate (schema, options, { name: ' MyPlugin' });
128
132
```
129
133
@@ -140,6 +144,11 @@ Default: `"configuration"`
140
144
Allow to setup base data path in validation errors.
141
145
142
146
``` js
147
+ import schema from ' ./path/to/schema.json' ;
148
+ import { validate } from ' schema-utils' ;
149
+
150
+ const options = { foo: ' bar' };
151
+
143
152
validate (schema, options, { name: ' MyPlugin' , baseDataPath: ' options' });
144
153
```
145
154
@@ -156,6 +165,11 @@ Default: `undefined`
156
165
Allow to reformat errors.
157
166
158
167
``` js
168
+ import schema from ' ./path/to/schema.json' ;
169
+ import { validate } from ' schema-utils' ;
170
+
171
+ const options = { foo: ' bar' };
172
+
159
173
validate (schema, options, {
160
174
name: ' MyPlugin' ,
161
175
postFormatter : (formattedError , error ) => {
@@ -207,14 +221,14 @@ Invalid options object. MyPlugin has been initialized using an options object th
207
221
208
222
``` js
209
223
import { getOptions } from ' loader-utils' ;
210
- import validateOptions from ' schema-utils' ;
224
+ import { validate } from ' schema-utils' ;
211
225
212
226
import schema from ' path/to/schema.json' ;
213
227
214
228
function loader (src , map ) {
215
- const options = getOptions (this ) || {} ;
229
+ const options = getOptions (this );
216
230
217
- validateOptions (schema, options, {
231
+ validate (schema, options, {
218
232
name: ' Loader Name' ,
219
233
baseDataPath: ' options' ,
220
234
});
@@ -228,13 +242,13 @@ export default loader;
228
242
### ` Plugin `
229
243
230
244
``` js
231
- import validateOptions from ' schema-utils' ;
245
+ import { validate } from ' schema-utils' ;
232
246
233
247
import schema from ' path/to/schema.json' ;
234
248
235
249
class Plugin {
236
250
constructor (options ) {
237
- validateOptions (schema, options, {
251
+ validate (schema, options, {
238
252
name: ' Plugin Name' ,
239
253
baseDataPath: ' options' ,
240
254
});
0 commit comments