table 3.7.10 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +34 -15
  2. package/dist/alignString.js +1 -3
  3. package/dist/alignTableData.js +1 -3
  4. package/dist/calculateCellHeight.js +2 -4
  5. package/dist/calculateCellWidthIndex.js +1 -3
  6. package/dist/calculateMaximumColumnWidthIndex.js +1 -3
  7. package/dist/calculateRowHeightIndex.js +1 -3
  8. package/dist/createStream.js +2 -4
  9. package/dist/drawRow.js +1 -3
  10. package/dist/drawTable.js +1 -3
  11. package/dist/getBorderCharacters.js +1 -3
  12. package/dist/index.js +4 -4
  13. package/dist/makeConfig.js +5 -7
  14. package/dist/makeStreamConfig.js +5 -7
  15. package/dist/mapDataUsingRowHeightIndex.js +1 -3
  16. package/dist/padTableData.js +1 -3
  17. package/dist/stringifyTableData.js +1 -3
  18. package/dist/table.js +2 -4
  19. package/dist/truncateTableData.js +1 -3
  20. package/dist/validateConfig.js +752 -58
  21. package/dist/validateStreamConfig.js +739 -50
  22. package/dist/validateTableData.js +1 -3
  23. package/dist/wrapString.js +1 -3
  24. package/dist/wrapWord.js +1 -3
  25. package/package.json +25 -7
  26. package/test/README/usage/basic.js +3 -1
  27. package/test/README/usage/cell_content_alignment.js +3 -1
  28. package/test/README/usage/column_width.js +3 -1
  29. package/test/README/usage/custom_border.js +3 -1
  30. package/test/README/usage/draw_horizontal_line.js +3 -1
  31. package/test/README/usage/moon_mission.js +3 -2
  32. package/test/README/usage/padding_cell_content.js +3 -1
  33. package/test/README/usage/predefined_border_templates.js +3 -2
  34. package/test/README/usage/text_truncating.js +3 -1
  35. package/test/README/usage/text_wrapping.js +3 -1
  36. package/test/config.js +43 -0
  37. package/test/configSamples.js +153 -0
  38. package/test/streamConfig.js +43 -0
  39. package/test/streamConfigSamples.js +151 -0
  40. package/test/wrapString.js +2 -2
  41. package/dist/alignString.js.map +0 -1
  42. package/dist/alignTableData.js.map +0 -1
  43. package/dist/calculateCellHeight.js.map +0 -1
  44. package/dist/calculateCellWidthIndex.js.map +0 -1
  45. package/dist/calculateMaximumColumnWidthIndex.js.map +0 -1
  46. package/dist/calculateRowHeightIndex.js.map +0 -1
  47. package/dist/createStream.js.map +0 -1
  48. package/dist/drawBorder.js.map +0 -1
  49. package/dist/drawRow.js.map +0 -1
  50. package/dist/drawTable.js.map +0 -1
  51. package/dist/getBorderCharacters.js.map +0 -1
  52. package/dist/index.js.map +0 -1
  53. package/dist/makeConfig.js.map +0 -1
  54. package/dist/makeStreamConfig.js.map +0 -1
  55. package/dist/mapDataUsingRowHeightIndex.js.map +0 -1
  56. package/dist/padTableData.js.map +0 -1
  57. package/dist/stringifyTableData.js.map +0 -1
  58. package/dist/table.js.map +0 -1
  59. package/dist/truncateTableData.js.map +0 -1
  60. package/dist/validateConfig.js.map +0 -1
  61. package/dist/validateStreamConfig.js.map +0 -1
  62. package/dist/validateTableData.js.map +0 -1
  63. package/dist/wrapString.js.map +0 -1
  64. package/dist/wrapWord.js.map +0 -1
@@ -1,62 +1,756 @@
1
1
  'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
-
7
- var _ajv = require('ajv');
8
-
9
- var _ajv2 = _interopRequireDefault(_ajv);
10
-
11
- var _ajvKeywords = require('ajv-keywords');
12
-
13
- var _ajvKeywords2 = _interopRequireDefault(_ajvKeywords);
14
-
15
- var _config = require('./schemas/config.json');
16
-
17
- var _config2 = _interopRequireDefault(_config);
18
-
19
- var _streamConfig = require('./schemas/streamConfig.json');
20
-
21
- var _streamConfig2 = _interopRequireDefault(_streamConfig);
22
-
23
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
-
25
- const ajv = new _ajv2.default({
26
- allErrors: true
27
- });
28
-
29
- (0, _ajvKeywords2.default)(ajv, 'typeof');
30
-
31
- ajv.addSchema(_config2.default);
32
- ajv.addSchema(_streamConfig2.default);
33
-
34
- /**
35
- * @param {string} schemaId
36
- * @param {formatData~config} config
37
- * @returns {undefined}
38
- */
39
-
40
- exports.default = function (schemaId) {
41
- let config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
42
-
43
- if (!ajv.validate(schemaId, config)) {
44
- const errors = ajv.errors.map(error => {
45
- return {
46
- dataPath: error.dataPath,
47
- message: error.message,
48
- params: error.params,
49
- schemaPath: error.schemaPath
2
+ var equal = require('ajv/lib/compile/equal');
3
+ var validate = (function() {
4
+ var pattern0 = new RegExp('^[0-9]+$');
5
+ var refVal = [];
6
+ var refVal1 = (function() {
7
+ var pattern0 = new RegExp('^[0-9]+$');
8
+ return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
9
+ 'use strict';
10
+ var vErrors = null;
11
+ var errors = 0;
12
+ if (rootData === undefined) rootData = data;
13
+ if ((data && typeof data === "object" && !Array.isArray(data))) {
14
+ var errs__0 = errors;
15
+ var valid1 = true;
16
+ for (var key0 in data) {
17
+ var isAdditional0 = !(false || validate.schema.properties[key0]);
18
+ if (isAdditional0) {
19
+ valid1 = false;
20
+ var err = {
21
+ keyword: 'additionalProperties',
22
+ dataPath: (dataPath || '') + "",
23
+ schemaPath: '#/additionalProperties',
24
+ params: {
25
+ additionalProperty: '' + key0 + ''
26
+ },
27
+ message: 'should NOT have additional properties'
28
+ };
29
+ if (vErrors === null) vErrors = [err];
30
+ else vErrors.push(err);
31
+ errors++;
32
+ }
33
+ }
34
+ if (data.topBody !== undefined) {
35
+ var errs_1 = errors;
36
+ if (!refVal2(data.topBody, (dataPath || '') + '.topBody', data, 'topBody', rootData)) {
37
+ if (vErrors === null) vErrors = refVal2.errors;
38
+ else vErrors = vErrors.concat(refVal2.errors);
39
+ errors = vErrors.length;
40
+ }
41
+ var valid1 = errors === errs_1;
42
+ }
43
+ if (data.topJoin !== undefined) {
44
+ var errs_1 = errors;
45
+ if (!refVal[2](data.topJoin, (dataPath || '') + '.topJoin', data, 'topJoin', rootData)) {
46
+ if (vErrors === null) vErrors = refVal[2].errors;
47
+ else vErrors = vErrors.concat(refVal[2].errors);
48
+ errors = vErrors.length;
49
+ }
50
+ var valid1 = errors === errs_1;
51
+ }
52
+ if (data.topLeft !== undefined) {
53
+ var errs_1 = errors;
54
+ if (!refVal[2](data.topLeft, (dataPath || '') + '.topLeft', data, 'topLeft', rootData)) {
55
+ if (vErrors === null) vErrors = refVal[2].errors;
56
+ else vErrors = vErrors.concat(refVal[2].errors);
57
+ errors = vErrors.length;
58
+ }
59
+ var valid1 = errors === errs_1;
60
+ }
61
+ if (data.topRight !== undefined) {
62
+ var errs_1 = errors;
63
+ if (!refVal[2](data.topRight, (dataPath || '') + '.topRight', data, 'topRight', rootData)) {
64
+ if (vErrors === null) vErrors = refVal[2].errors;
65
+ else vErrors = vErrors.concat(refVal[2].errors);
66
+ errors = vErrors.length;
67
+ }
68
+ var valid1 = errors === errs_1;
69
+ }
70
+ if (data.bottomBody !== undefined) {
71
+ var errs_1 = errors;
72
+ if (!refVal[2](data.bottomBody, (dataPath || '') + '.bottomBody', data, 'bottomBody', rootData)) {
73
+ if (vErrors === null) vErrors = refVal[2].errors;
74
+ else vErrors = vErrors.concat(refVal[2].errors);
75
+ errors = vErrors.length;
76
+ }
77
+ var valid1 = errors === errs_1;
78
+ }
79
+ if (data.bottomJoin !== undefined) {
80
+ var errs_1 = errors;
81
+ if (!refVal[2](data.bottomJoin, (dataPath || '') + '.bottomJoin', data, 'bottomJoin', rootData)) {
82
+ if (vErrors === null) vErrors = refVal[2].errors;
83
+ else vErrors = vErrors.concat(refVal[2].errors);
84
+ errors = vErrors.length;
85
+ }
86
+ var valid1 = errors === errs_1;
87
+ }
88
+ if (data.bottomLeft !== undefined) {
89
+ var errs_1 = errors;
90
+ if (!refVal[2](data.bottomLeft, (dataPath || '') + '.bottomLeft', data, 'bottomLeft', rootData)) {
91
+ if (vErrors === null) vErrors = refVal[2].errors;
92
+ else vErrors = vErrors.concat(refVal[2].errors);
93
+ errors = vErrors.length;
94
+ }
95
+ var valid1 = errors === errs_1;
96
+ }
97
+ if (data.bottomRight !== undefined) {
98
+ var errs_1 = errors;
99
+ if (!refVal[2](data.bottomRight, (dataPath || '') + '.bottomRight', data, 'bottomRight', rootData)) {
100
+ if (vErrors === null) vErrors = refVal[2].errors;
101
+ else vErrors = vErrors.concat(refVal[2].errors);
102
+ errors = vErrors.length;
103
+ }
104
+ var valid1 = errors === errs_1;
105
+ }
106
+ if (data.bodyLeft !== undefined) {
107
+ var errs_1 = errors;
108
+ if (!refVal[2](data.bodyLeft, (dataPath || '') + '.bodyLeft', data, 'bodyLeft', rootData)) {
109
+ if (vErrors === null) vErrors = refVal[2].errors;
110
+ else vErrors = vErrors.concat(refVal[2].errors);
111
+ errors = vErrors.length;
112
+ }
113
+ var valid1 = errors === errs_1;
114
+ }
115
+ if (data.bodyRight !== undefined) {
116
+ var errs_1 = errors;
117
+ if (!refVal[2](data.bodyRight, (dataPath || '') + '.bodyRight', data, 'bodyRight', rootData)) {
118
+ if (vErrors === null) vErrors = refVal[2].errors;
119
+ else vErrors = vErrors.concat(refVal[2].errors);
120
+ errors = vErrors.length;
121
+ }
122
+ var valid1 = errors === errs_1;
123
+ }
124
+ if (data.bodyJoin !== undefined) {
125
+ var errs_1 = errors;
126
+ if (!refVal[2](data.bodyJoin, (dataPath || '') + '.bodyJoin', data, 'bodyJoin', rootData)) {
127
+ if (vErrors === null) vErrors = refVal[2].errors;
128
+ else vErrors = vErrors.concat(refVal[2].errors);
129
+ errors = vErrors.length;
130
+ }
131
+ var valid1 = errors === errs_1;
132
+ }
133
+ if (data.joinBody !== undefined) {
134
+ var errs_1 = errors;
135
+ if (!refVal[2](data.joinBody, (dataPath || '') + '.joinBody', data, 'joinBody', rootData)) {
136
+ if (vErrors === null) vErrors = refVal[2].errors;
137
+ else vErrors = vErrors.concat(refVal[2].errors);
138
+ errors = vErrors.length;
139
+ }
140
+ var valid1 = errors === errs_1;
141
+ }
142
+ if (data.joinLeft !== undefined) {
143
+ var errs_1 = errors;
144
+ if (!refVal[2](data.joinLeft, (dataPath || '') + '.joinLeft', data, 'joinLeft', rootData)) {
145
+ if (vErrors === null) vErrors = refVal[2].errors;
146
+ else vErrors = vErrors.concat(refVal[2].errors);
147
+ errors = vErrors.length;
148
+ }
149
+ var valid1 = errors === errs_1;
150
+ }
151
+ if (data.joinRight !== undefined) {
152
+ var errs_1 = errors;
153
+ if (!refVal[2](data.joinRight, (dataPath || '') + '.joinRight', data, 'joinRight', rootData)) {
154
+ if (vErrors === null) vErrors = refVal[2].errors;
155
+ else vErrors = vErrors.concat(refVal[2].errors);
156
+ errors = vErrors.length;
157
+ }
158
+ var valid1 = errors === errs_1;
159
+ }
160
+ if (data.joinJoin !== undefined) {
161
+ var errs_1 = errors;
162
+ if (!refVal[2](data.joinJoin, (dataPath || '') + '.joinJoin', data, 'joinJoin', rootData)) {
163
+ if (vErrors === null) vErrors = refVal[2].errors;
164
+ else vErrors = vErrors.concat(refVal[2].errors);
165
+ errors = vErrors.length;
166
+ }
167
+ var valid1 = errors === errs_1;
168
+ }
169
+ } else {
170
+ var err = {
171
+ keyword: 'type',
172
+ dataPath: (dataPath || '') + "",
173
+ schemaPath: '#/type',
174
+ params: {
175
+ type: 'object'
176
+ },
177
+ message: 'should be object'
178
+ };
179
+ if (vErrors === null) vErrors = [err];
180
+ else vErrors.push(err);
181
+ errors++;
182
+ }
183
+ validate.errors = vErrors;
184
+ return errors === 0;
185
+ };
186
+ })();
187
+ refVal1.schema = {
188
+ "type": "object",
189
+ "properties": {
190
+ "topBody": {
191
+ "$ref": "#/definitions/border"
192
+ },
193
+ "topJoin": {
194
+ "$ref": "#/definitions/border"
195
+ },
196
+ "topLeft": {
197
+ "$ref": "#/definitions/border"
198
+ },
199
+ "topRight": {
200
+ "$ref": "#/definitions/border"
201
+ },
202
+ "bottomBody": {
203
+ "$ref": "#/definitions/border"
204
+ },
205
+ "bottomJoin": {
206
+ "$ref": "#/definitions/border"
207
+ },
208
+ "bottomLeft": {
209
+ "$ref": "#/definitions/border"
210
+ },
211
+ "bottomRight": {
212
+ "$ref": "#/definitions/border"
213
+ },
214
+ "bodyLeft": {
215
+ "$ref": "#/definitions/border"
216
+ },
217
+ "bodyRight": {
218
+ "$ref": "#/definitions/border"
219
+ },
220
+ "bodyJoin": {
221
+ "$ref": "#/definitions/border"
222
+ },
223
+ "joinBody": {
224
+ "$ref": "#/definitions/border"
225
+ },
226
+ "joinLeft": {
227
+ "$ref": "#/definitions/border"
228
+ },
229
+ "joinRight": {
230
+ "$ref": "#/definitions/border"
231
+ },
232
+ "joinJoin": {
233
+ "$ref": "#/definitions/border"
234
+ }
235
+ },
236
+ "additionalProperties": false
237
+ };
238
+ refVal1.errors = null;
239
+ refVal[1] = refVal1;
240
+ var refVal2 = (function() {
241
+ var pattern0 = new RegExp('^[0-9]+$');
242
+ return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
243
+ 'use strict';
244
+ var vErrors = null;
245
+ var errors = 0;
246
+ if (rootData === undefined) rootData = data;
247
+ if (typeof data !== "string") {
248
+ var err = {
249
+ keyword: 'type',
250
+ dataPath: (dataPath || '') + "",
251
+ schemaPath: '#/type',
252
+ params: {
253
+ type: 'string'
254
+ },
255
+ message: 'should be string'
256
+ };
257
+ if (vErrors === null) vErrors = [err];
258
+ else vErrors.push(err);
259
+ errors++;
260
+ }
261
+ validate.errors = vErrors;
262
+ return errors === 0;
263
+ };
264
+ })();
265
+ refVal2.schema = {
266
+ "type": "string"
267
+ };
268
+ refVal2.errors = null;
269
+ refVal[2] = refVal2;
270
+ var refVal3 = (function() {
271
+ var pattern0 = new RegExp('^[0-9]+$');
272
+ return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
273
+ 'use strict';
274
+ var vErrors = null;
275
+ var errors = 0;
276
+ if (rootData === undefined) rootData = data;
277
+ if ((data && typeof data === "object" && !Array.isArray(data))) {
278
+ var errs__0 = errors;
279
+ var valid1 = true;
280
+ for (var key0 in data) {
281
+ var isAdditional0 = !(false || pattern0.test(key0));
282
+ if (isAdditional0) {
283
+ valid1 = false;
284
+ var err = {
285
+ keyword: 'additionalProperties',
286
+ dataPath: (dataPath || '') + "",
287
+ schemaPath: '#/additionalProperties',
288
+ params: {
289
+ additionalProperty: '' + key0 + ''
290
+ },
291
+ message: 'should NOT have additional properties'
292
+ };
293
+ if (vErrors === null) vErrors = [err];
294
+ else vErrors.push(err);
295
+ errors++;
296
+ }
297
+ }
298
+ for (var key0 in data) {
299
+ if (pattern0.test(key0)) {
300
+ var errs_1 = errors;
301
+ if (!refVal4(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, rootData)) {
302
+ if (vErrors === null) vErrors = refVal4.errors;
303
+ else vErrors = vErrors.concat(refVal4.errors);
304
+ errors = vErrors.length;
305
+ }
306
+ var valid1 = errors === errs_1;
307
+ }
308
+ }
309
+ } else {
310
+ var err = {
311
+ keyword: 'type',
312
+ dataPath: (dataPath || '') + "",
313
+ schemaPath: '#/type',
314
+ params: {
315
+ type: 'object'
316
+ },
317
+ message: 'should be object'
318
+ };
319
+ if (vErrors === null) vErrors = [err];
320
+ else vErrors.push(err);
321
+ errors++;
322
+ }
323
+ validate.errors = vErrors;
324
+ return errors === 0;
325
+ };
326
+ })();
327
+ refVal3.schema = {
328
+ "type": "object",
329
+ "patternProperties": {
330
+ "^[0-9]+$": {
331
+ "$ref": "#/definitions/column"
332
+ }
333
+ },
334
+ "additionalProperties": false
335
+ };
336
+ refVal3.errors = null;
337
+ refVal[3] = refVal3;
338
+ var refVal4 = (function() {
339
+ var pattern0 = new RegExp('^[0-9]+$');
340
+ return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
341
+ 'use strict';
342
+ var vErrors = null;
343
+ var errors = 0;
344
+ if (rootData === undefined) rootData = data;
345
+ if ((data && typeof data === "object" && !Array.isArray(data))) {
346
+ var errs__0 = errors;
347
+ var valid1 = true;
348
+ for (var key0 in data) {
349
+ var isAdditional0 = !(false || validate.schema.properties[key0]);
350
+ if (isAdditional0) {
351
+ valid1 = false;
352
+ var err = {
353
+ keyword: 'additionalProperties',
354
+ dataPath: (dataPath || '') + "",
355
+ schemaPath: '#/additionalProperties',
356
+ params: {
357
+ additionalProperty: '' + key0 + ''
358
+ },
359
+ message: 'should NOT have additional properties'
360
+ };
361
+ if (vErrors === null) vErrors = [err];
362
+ else vErrors.push(err);
363
+ errors++;
364
+ }
365
+ }
366
+ var data1 = data.alignment;
367
+ if (data1 !== undefined) {
368
+ var errs_1 = errors;
369
+ var schema1 = validate.schema.properties.alignment.enum;
370
+ var valid1;
371
+ valid1 = false;
372
+ for (var i1 = 0; i1 < schema1.length; i1++)
373
+ if (equal(data1, schema1[i1])) {
374
+ valid1 = true;
375
+ break;
376
+ }
377
+ if (!valid1) {
378
+ var err = {
379
+ keyword: 'enum',
380
+ dataPath: (dataPath || '') + '.alignment',
381
+ schemaPath: '#/properties/alignment/enum',
382
+ params: {
383
+ allowedValues: schema1
384
+ },
385
+ message: 'should be equal to one of the allowed values'
386
+ };
387
+ if (vErrors === null) vErrors = [err];
388
+ else vErrors.push(err);
389
+ errors++;
390
+ }
391
+ if (typeof data1 !== "string") {
392
+ var err = {
393
+ keyword: 'type',
394
+ dataPath: (dataPath || '') + '.alignment',
395
+ schemaPath: '#/properties/alignment/type',
396
+ params: {
397
+ type: 'string'
398
+ },
399
+ message: 'should be string'
400
+ };
401
+ if (vErrors === null) vErrors = [err];
402
+ else vErrors.push(err);
403
+ errors++;
404
+ }
405
+ var valid1 = errors === errs_1;
406
+ }
407
+ if (data.width !== undefined) {
408
+ var errs_1 = errors;
409
+ if (typeof data.width !== "number") {
410
+ var err = {
411
+ keyword: 'type',
412
+ dataPath: (dataPath || '') + '.width',
413
+ schemaPath: '#/properties/width/type',
414
+ params: {
415
+ type: 'number'
416
+ },
417
+ message: 'should be number'
418
+ };
419
+ if (vErrors === null) vErrors = [err];
420
+ else vErrors.push(err);
421
+ errors++;
422
+ }
423
+ var valid1 = errors === errs_1;
424
+ }
425
+ if (data.wrapWord !== undefined) {
426
+ var errs_1 = errors;
427
+ if (typeof data.wrapWord !== "boolean") {
428
+ var err = {
429
+ keyword: 'type',
430
+ dataPath: (dataPath || '') + '.wrapWord',
431
+ schemaPath: '#/properties/wrapWord/type',
432
+ params: {
433
+ type: 'boolean'
434
+ },
435
+ message: 'should be boolean'
436
+ };
437
+ if (vErrors === null) vErrors = [err];
438
+ else vErrors.push(err);
439
+ errors++;
440
+ }
441
+ var valid1 = errors === errs_1;
442
+ }
443
+ if (data.truncate !== undefined) {
444
+ var errs_1 = errors;
445
+ if (typeof data.truncate !== "number") {
446
+ var err = {
447
+ keyword: 'type',
448
+ dataPath: (dataPath || '') + '.truncate',
449
+ schemaPath: '#/properties/truncate/type',
450
+ params: {
451
+ type: 'number'
452
+ },
453
+ message: 'should be number'
454
+ };
455
+ if (vErrors === null) vErrors = [err];
456
+ else vErrors.push(err);
457
+ errors++;
458
+ }
459
+ var valid1 = errors === errs_1;
460
+ }
461
+ if (data.paddingLeft !== undefined) {
462
+ var errs_1 = errors;
463
+ if (typeof data.paddingLeft !== "number") {
464
+ var err = {
465
+ keyword: 'type',
466
+ dataPath: (dataPath || '') + '.paddingLeft',
467
+ schemaPath: '#/properties/paddingLeft/type',
468
+ params: {
469
+ type: 'number'
470
+ },
471
+ message: 'should be number'
472
+ };
473
+ if (vErrors === null) vErrors = [err];
474
+ else vErrors.push(err);
475
+ errors++;
476
+ }
477
+ var valid1 = errors === errs_1;
478
+ }
479
+ if (data.paddingRight !== undefined) {
480
+ var errs_1 = errors;
481
+ if (typeof data.paddingRight !== "number") {
482
+ var err = {
483
+ keyword: 'type',
484
+ dataPath: (dataPath || '') + '.paddingRight',
485
+ schemaPath: '#/properties/paddingRight/type',
486
+ params: {
487
+ type: 'number'
488
+ },
489
+ message: 'should be number'
490
+ };
491
+ if (vErrors === null) vErrors = [err];
492
+ else vErrors.push(err);
493
+ errors++;
494
+ }
495
+ var valid1 = errors === errs_1;
496
+ }
497
+ } else {
498
+ var err = {
499
+ keyword: 'type',
500
+ dataPath: (dataPath || '') + "",
501
+ schemaPath: '#/type',
502
+ params: {
503
+ type: 'object'
504
+ },
505
+ message: 'should be object'
506
+ };
507
+ if (vErrors === null) vErrors = [err];
508
+ else vErrors.push(err);
509
+ errors++;
510
+ }
511
+ validate.errors = vErrors;
512
+ return errors === 0;
513
+ };
514
+ })();
515
+ refVal4.schema = {
516
+ "type": "object",
517
+ "properties": {
518
+ "alignment": {
519
+ "type": "string",
520
+ "enum": ["left", "right", "center"]
521
+ },
522
+ "width": {
523
+ "type": "number"
524
+ },
525
+ "wrapWord": {
526
+ "type": "boolean"
527
+ },
528
+ "truncate": {
529
+ "type": "number"
530
+ },
531
+ "paddingLeft": {
532
+ "type": "number"
533
+ },
534
+ "paddingRight": {
535
+ "type": "number"
536
+ }
537
+ },
538
+ "additionalProperties": false
539
+ };
540
+ refVal4.errors = null;
541
+ refVal[4] = refVal4;
542
+ return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
543
+ 'use strict';
544
+ var vErrors = null;
545
+ var errors = 0;
546
+ if (rootData === undefined) rootData = data;
547
+ if ((data && typeof data === "object" && !Array.isArray(data))) {
548
+ var errs__0 = errors;
549
+ var valid1 = true;
550
+ for (var key0 in data) {
551
+ var isAdditional0 = !(false || key0 == 'border' || key0 == 'columns' || key0 == 'columnDefault' || key0 == 'drawHorizontalLine');
552
+ if (isAdditional0) {
553
+ valid1 = false;
554
+ var err = {
555
+ keyword: 'additionalProperties',
556
+ dataPath: (dataPath || '') + "",
557
+ schemaPath: '#/additionalProperties',
558
+ params: {
559
+ additionalProperty: '' + key0 + ''
560
+ },
561
+ message: 'should NOT have additional properties'
562
+ };
563
+ if (vErrors === null) vErrors = [err];
564
+ else vErrors.push(err);
565
+ errors++;
566
+ }
567
+ }
568
+ if (data.border !== undefined) {
569
+ var errs_1 = errors;
570
+ if (!refVal1(data.border, (dataPath || '') + '.border', data, 'border', rootData)) {
571
+ if (vErrors === null) vErrors = refVal1.errors;
572
+ else vErrors = vErrors.concat(refVal1.errors);
573
+ errors = vErrors.length;
574
+ }
575
+ var valid1 = errors === errs_1;
576
+ }
577
+ if (data.columns !== undefined) {
578
+ var errs_1 = errors;
579
+ if (!refVal3(data.columns, (dataPath || '') + '.columns', data, 'columns', rootData)) {
580
+ if (vErrors === null) vErrors = refVal3.errors;
581
+ else vErrors = vErrors.concat(refVal3.errors);
582
+ errors = vErrors.length;
583
+ }
584
+ var valid1 = errors === errs_1;
585
+ }
586
+ if (data.columnDefault !== undefined) {
587
+ var errs_1 = errors;
588
+ if (!refVal[4](data.columnDefault, (dataPath || '') + '.columnDefault', data, 'columnDefault', rootData)) {
589
+ if (vErrors === null) vErrors = refVal[4].errors;
590
+ else vErrors = vErrors.concat(refVal[4].errors);
591
+ errors = vErrors.length;
592
+ }
593
+ var valid1 = errors === errs_1;
594
+ }
595
+ if (data.drawHorizontalLine !== undefined) {
596
+ var errs_1 = errors;
597
+ var errs__1 = errors;
598
+ var valid1;
599
+ if (!(typeof data.drawHorizontalLine == "function")) {
600
+ if (errs__1 == errors) {
601
+ var err = {
602
+ keyword: 'typeof',
603
+ dataPath: (dataPath || '') + '.drawHorizontalLine',
604
+ schemaPath: '#/properties/drawHorizontalLine/typeof',
605
+ params: {
606
+ keyword: 'typeof'
607
+ },
608
+ message: 'should pass "typeof" keyword validation'
609
+ };
610
+ if (vErrors === null) vErrors = [err];
611
+ else vErrors.push(err);
612
+ errors++;
613
+ } else {
614
+ for (var i1 = errs__1; i1 < errors; i1++) {
615
+ var ruleErr1 = vErrors[i1];
616
+ if (ruleErr1.dataPath === undefined) {
617
+ ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine';
618
+ }
619
+ if (ruleErr1.schemaPath === undefined) {
620
+ ruleErr1.schemaPath = "#/properties/drawHorizontalLine/typeof";
621
+ }
622
+ }
623
+ }
624
+ }
625
+ var valid1 = errors === errs_1;
626
+ }
627
+ } else {
628
+ var err = {
629
+ keyword: 'type',
630
+ dataPath: (dataPath || '') + "",
631
+ schemaPath: '#/type',
632
+ params: {
633
+ type: 'object'
634
+ },
635
+ message: 'should be object'
50
636
  };
51
- });
52
-
53
- /* eslint-disable no-console */
54
- console.log('config', config);
55
- console.log('errors', errors);
56
- /* eslint-enable no-console */
57
-
58
- throw new Error('Invalid config.');
637
+ if (vErrors === null) vErrors = [err];
638
+ else vErrors.push(err);
639
+ errors++;
640
+ }
641
+ validate.errors = vErrors;
642
+ return errors === 0;
643
+ };
644
+ })();
645
+ validate.schema = {
646
+ "id": "config.json",
647
+ "$schema": "http://json-schema.org/draft-04/schema#",
648
+ "type": "object",
649
+ "properties": {
650
+ "border": {
651
+ "$ref": "#/definitions/borders"
652
+ },
653
+ "columns": {
654
+ "$ref": "#/definitions/columns"
655
+ },
656
+ "columnDefault": {
657
+ "$ref": "#/definitions/column"
658
+ },
659
+ "drawHorizontalLine": {
660
+ "typeof": "function"
661
+ }
662
+ },
663
+ "additionalProperties": false,
664
+ "definitions": {
665
+ "columns": {
666
+ "type": "object",
667
+ "patternProperties": {
668
+ "^[0-9]+$": {
669
+ "$ref": "#/definitions/column"
670
+ }
671
+ },
672
+ "additionalProperties": false
673
+ },
674
+ "column": {
675
+ "type": "object",
676
+ "properties": {
677
+ "alignment": {
678
+ "type": "string",
679
+ "enum": ["left", "right", "center"]
680
+ },
681
+ "width": {
682
+ "type": "number"
683
+ },
684
+ "wrapWord": {
685
+ "type": "boolean"
686
+ },
687
+ "truncate": {
688
+ "type": "number"
689
+ },
690
+ "paddingLeft": {
691
+ "type": "number"
692
+ },
693
+ "paddingRight": {
694
+ "type": "number"
695
+ }
696
+ },
697
+ "additionalProperties": false
698
+ },
699
+ "borders": {
700
+ "type": "object",
701
+ "properties": {
702
+ "topBody": {
703
+ "$ref": "#/definitions/border"
704
+ },
705
+ "topJoin": {
706
+ "$ref": "#/definitions/border"
707
+ },
708
+ "topLeft": {
709
+ "$ref": "#/definitions/border"
710
+ },
711
+ "topRight": {
712
+ "$ref": "#/definitions/border"
713
+ },
714
+ "bottomBody": {
715
+ "$ref": "#/definitions/border"
716
+ },
717
+ "bottomJoin": {
718
+ "$ref": "#/definitions/border"
719
+ },
720
+ "bottomLeft": {
721
+ "$ref": "#/definitions/border"
722
+ },
723
+ "bottomRight": {
724
+ "$ref": "#/definitions/border"
725
+ },
726
+ "bodyLeft": {
727
+ "$ref": "#/definitions/border"
728
+ },
729
+ "bodyRight": {
730
+ "$ref": "#/definitions/border"
731
+ },
732
+ "bodyJoin": {
733
+ "$ref": "#/definitions/border"
734
+ },
735
+ "joinBody": {
736
+ "$ref": "#/definitions/border"
737
+ },
738
+ "joinLeft": {
739
+ "$ref": "#/definitions/border"
740
+ },
741
+ "joinRight": {
742
+ "$ref": "#/definitions/border"
743
+ },
744
+ "joinJoin": {
745
+ "$ref": "#/definitions/border"
746
+ }
747
+ },
748
+ "additionalProperties": false
749
+ },
750
+ "border": {
751
+ "type": "string"
752
+ }
59
753
  }
60
754
  };
61
-
62
- module.exports = exports['default'];
755
+ validate.errors = null;
756
+ module.exports = validate;