definition-generator-framework 1.12.5 → 1.12.7
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.
- package/dist/framework/definition-component.d.ts +11 -9
- package/dist/framework/definition-component.js +18 -18
- package/dist/framework/definition-generator.d.ts +6 -5
- package/dist/framework/definition-generator.js +16 -18
- package/dist/framework/file-content-generator/file-content-generator.js +1 -1
- package/dist/framework/file-content-generator/file-content-generator.test.js +49 -49
- package/dist/framework/framework.d.ts +14 -13
- package/dist/framework/framework.data.d.ts +3 -3
- package/dist/framework/framework.data.js +13 -7
- package/dist/framework/framework.js +36 -33
- package/dist/framework/framework.model.d.ts +15 -15
- package/dist/framework/framework.model.js +3 -3
- package/dist/framework/index-file-generator/index-file-generator.js +2 -4
- package/dist/helpers/common-functions/common-functions.js +1 -1
- package/dist/helpers/common-functions/common-functions.spec.js +48 -48
- package/dist/helpers/duplicate-helper/duplicate-helper.spec.js +52 -52
- package/dist/helpers/output-helper/output-helper.d.ts +26 -26
- package/dist/helpers/output-helper/output-helper.js +127 -107
- package/dist/helpers/output-helper/output-helper.spec.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.spec.js +223 -211
- package/dist/helpers/output-helper/output-helper.test.d.ts +22 -22
- package/dist/helpers/output-helper/output-helper.test.js +224 -212
- package/dist/helpers/raw-definition-helper/raw-definition.helper.spec.js +133 -125
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.d.ts +1 -1
- package/dist/helpers/validator/custom-validator-helper/custom-validator.helper.spec.js +174 -156
- package/dist/helpers/validator/custom-validators/image.custom-validator.d.ts +6 -6
- package/dist/helpers/validator/custom-validators/image.custom-validator.js +40 -39
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.d.ts +4 -4
- package/dist/helpers/validator/custom-validators/unique-name-group.custom-validator.js +29 -29
- package/dist/helpers/validator/joi-custom-validators.spec.js +284 -240
- package/dist/helpers/validator/validator.spec.js +313 -303
- package/dist/pipeline/1-select-definitions-helper.d.ts +13 -13
- package/dist/pipeline/1-select-definitions-helper.js +68 -72
- package/dist/pipeline/1-select-definitions.helper.test.js +40 -40
- package/dist/pipeline/1-select-definitions.spec.js +131 -131
- package/dist/pipeline/2-structure-parser.helper.spec.js +266 -266
- package/dist/pipeline/parsers/array-parser.spec.js +116 -113
- package/dist/pipeline/parsers/object-parser.spec.js +159 -153
- package/dist/pipeline/parsers/primitive-parser.spec.js +67 -67
- package/dist/pre-made-components/assets/3-font.js +4 -4
- package/dist/pre-made-components/events/1-event.d.ts +1 -1
- package/dist/pre-made-components/events/1-event.js +157 -125
- package/dist/pre-made-components/events/2-event-test.d.ts +8 -8
- package/dist/pre-made-components/events/2-event-test.js +156 -119
- package/dist/pre-made-components/events/2-script-test.js +0 -1
- package/dist/pre-made-components/events/event-setup.d.ts +10 -5
- package/dist/pre-made-components/events/event-setup.js +15 -15
- package/dist/pre-made-components/events/script-setup.d.ts +5 -3
- package/dist/pre-made-components/events/script-setup.js +11 -11
- package/package.json +5 -10
|
@@ -1,260 +1,304 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __setModuleDefault =
|
|
23
|
+
(this && this.__setModuleDefault) ||
|
|
24
|
+
(Object.create
|
|
25
|
+
? function (o, v) {
|
|
26
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
+
}
|
|
28
|
+
: function (o, v) {
|
|
29
|
+
o['default'] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar =
|
|
32
|
+
(this && this.__importStar) ||
|
|
33
|
+
function (mod) {
|
|
19
34
|
if (mod && mod.__esModule) return mod;
|
|
20
35
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
36
|
+
if (mod != null)
|
|
37
|
+
for (var k in mod) if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
38
|
__setModuleDefault(result, mod);
|
|
23
39
|
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports,
|
|
26
|
-
const Joi = __importStar(require(
|
|
27
|
-
const joi_custom_validators_1 = require(
|
|
28
|
-
const mocks_1 = require(
|
|
29
|
-
const raw_definition_helper_1 = require(
|
|
30
|
-
joi_custom_validators_1.JoiCustomValidators.decorate({ existsSync:
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
42
|
+
const Joi = __importStar(require('joi'));
|
|
43
|
+
const joi_custom_validators_1 = require('./joi-custom-validators');
|
|
44
|
+
const mocks_1 = require('../../_mocks/mocks');
|
|
45
|
+
const raw_definition_helper_1 = require('../raw-definition-helper/raw-definition.helper');
|
|
46
|
+
joi_custom_validators_1.JoiCustomValidators.decorate({ existsSync: path => path !== 'D:/test/false/path.png' });
|
|
31
47
|
const DefinitionType = 'ASSET';
|
|
32
48
|
class Asset {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
49
|
+
static {
|
|
50
|
+
this.$meta = {
|
|
51
|
+
definitionName: DefinitionType
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async process() {}
|
|
37
55
|
}
|
|
38
56
|
class AssetGroup {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
static {
|
|
58
|
+
this.$meta = {
|
|
59
|
+
definitionName: 'ASSET-GROUP'
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async process() {}
|
|
43
63
|
}
|
|
44
64
|
function getSimpleRawDefinition(value, offset = 1) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
65
|
+
return {
|
|
66
|
+
type: DefinitionType,
|
|
67
|
+
location: mocks_1.SampleLocation1,
|
|
68
|
+
parsedStructure: {
|
|
69
|
+
line: mocks_1.SampleLocation1.line + offset,
|
|
70
|
+
rawData: {
|
|
71
|
+
value: {
|
|
72
|
+
rawData: value,
|
|
73
|
+
line: mocks_1.SampleLocation1.line + offset
|
|
56
74
|
}
|
|
57
|
-
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
58
78
|
}
|
|
59
79
|
function getFlatRawDefinition(value, offset = 1) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
80
|
+
return {
|
|
81
|
+
type: DefinitionType,
|
|
82
|
+
location: mocks_1.SampleLocation1,
|
|
83
|
+
parsedStructure: {
|
|
84
|
+
line: mocks_1.SampleLocation1.line + offset,
|
|
85
|
+
rawData: value
|
|
86
|
+
}
|
|
87
|
+
};
|
|
68
88
|
}
|
|
69
89
|
describe('JOI CUSTOM VALIDATORS', () => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
beforeEach(() => {
|
|
91
|
+
let validators = joi_custom_validators_1.JoiCustomValidators;
|
|
92
|
+
validators.rootDirectory = 'D:/';
|
|
93
|
+
validators.definitionNames = new Map();
|
|
94
|
+
validators.duplicateHelpers = new Map();
|
|
95
|
+
});
|
|
96
|
+
describe('Variable Name', () => {
|
|
97
|
+
let schema = Joi.object().keys({
|
|
98
|
+
value: Joi.string().uniqueNameGroup(Asset).required()
|
|
99
|
+
});
|
|
100
|
+
test('valid data', () => {
|
|
101
|
+
let rawDefinition = getSimpleRawDefinition('test');
|
|
102
|
+
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
103
|
+
abortEarly: false,
|
|
104
|
+
context: rawDefinition
|
|
105
|
+
});
|
|
106
|
+
expect(value).toEqual({ value: 'assetTest' });
|
|
107
|
+
expect(error).toEqual(undefined);
|
|
108
|
+
});
|
|
109
|
+
test('invalid data', () => {
|
|
110
|
+
let rawDefinition = getSimpleRawDefinition('invalid data');
|
|
111
|
+
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
112
|
+
abortEarly: false,
|
|
113
|
+
context: rawDefinition
|
|
114
|
+
});
|
|
115
|
+
expect(error?.details).toStrictEqual([
|
|
116
|
+
{
|
|
117
|
+
message: '"value" with value "invalid data" fails to match the required pattern: /^[a-z]+([a-zA-Z0-9]+)*$/',
|
|
118
|
+
path: [],
|
|
119
|
+
type: 'string.pattern.base',
|
|
120
|
+
context: {
|
|
121
|
+
name: undefined,
|
|
122
|
+
regex: /^[a-z]+([a-zA-Z0-9]+)*$/,
|
|
123
|
+
value: 'invalid data',
|
|
124
|
+
label: 'value',
|
|
125
|
+
key: 'value'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
]);
|
|
75
129
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
test('different groups should not create duplicates', () => {
|
|
126
|
-
let schema2 = Joi.object().keys({
|
|
127
|
-
value: Joi.string().uniqueNameGroup(AssetGroup).required()
|
|
128
|
-
});
|
|
129
|
-
let rawDefinition1 = getSimpleRawDefinition('test', 1);
|
|
130
|
-
let rawDefinition2 = getSimpleRawDefinition('test', 2);
|
|
131
|
-
schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), { abortEarly: false, context: rawDefinition1 });
|
|
132
|
-
schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), { abortEarly: false, context: rawDefinition2 });
|
|
133
|
-
let context = (0, mocks_1.getMockContext)();
|
|
134
|
-
joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
|
|
135
|
-
expect(context.errorLogs).toStrictEqual([]);
|
|
136
|
-
});
|
|
130
|
+
test('should detect duplicate variable names', () => {
|
|
131
|
+
let rawDefinition1 = getSimpleRawDefinition('test', 1);
|
|
132
|
+
let rawDefinition2 = getSimpleRawDefinition('test', 2);
|
|
133
|
+
schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), {
|
|
134
|
+
abortEarly: false,
|
|
135
|
+
context: rawDefinition1
|
|
136
|
+
});
|
|
137
|
+
schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), {
|
|
138
|
+
abortEarly: false,
|
|
139
|
+
context: rawDefinition2
|
|
140
|
+
});
|
|
141
|
+
let context = (0, mocks_1.getMockContext)();
|
|
142
|
+
joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
|
|
143
|
+
expect(context.errorLogs).toStrictEqual([
|
|
144
|
+
{
|
|
145
|
+
description: 'Value should be singular! Group: "ASSET", Value: "test"',
|
|
146
|
+
location: { line: mocks_1.SampleLocation1.line + 1, path: 'D:/test/file-1.md' }
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
description: 'Value should be singular! Group: "ASSET", Value: "test"',
|
|
150
|
+
location: { line: mocks_1.SampleLocation1.line + 2, path: 'D:/test/file-1.md' }
|
|
151
|
+
}
|
|
152
|
+
]);
|
|
153
|
+
});
|
|
154
|
+
test('different groups should not create duplicates', () => {
|
|
155
|
+
let schema2 = Joi.object().keys({
|
|
156
|
+
value: Joi.string().uniqueNameGroup(AssetGroup).required()
|
|
157
|
+
});
|
|
158
|
+
let rawDefinition1 = getSimpleRawDefinition('test', 1);
|
|
159
|
+
let rawDefinition2 = getSimpleRawDefinition('test', 2);
|
|
160
|
+
schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition1), {
|
|
161
|
+
abortEarly: false,
|
|
162
|
+
context: rawDefinition1
|
|
163
|
+
});
|
|
164
|
+
schema2.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition2), {
|
|
165
|
+
abortEarly: false,
|
|
166
|
+
context: rawDefinition2
|
|
167
|
+
});
|
|
168
|
+
let context = (0, mocks_1.getMockContext)();
|
|
169
|
+
joi_custom_validators_1.JoiCustomValidators.logDuplicates(context);
|
|
170
|
+
expect(context.errorLogs).toStrictEqual([]);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
describe('Reference', () => {
|
|
174
|
+
let schema = Joi.object().keys({
|
|
175
|
+
value: Joi.string().reference(Asset).required()
|
|
176
|
+
});
|
|
177
|
+
let multipleSchema = Joi.object().keys({
|
|
178
|
+
value: Joi.string().reference([AssetGroup, Asset]).required()
|
|
137
179
|
});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
path: ['value'],
|
|
191
|
-
type: 'any.custom'
|
|
192
|
-
}
|
|
193
|
-
]);
|
|
194
|
-
});
|
|
195
|
-
test('should detect non existing multiple references', () => {
|
|
196
|
-
let rawDefinition = getSimpleRawDefinition('test');
|
|
197
|
-
let { error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
198
|
-
abortEarly: false,
|
|
199
|
-
context: rawDefinition
|
|
200
|
-
});
|
|
201
|
-
expect(error?.details).toEqual([
|
|
202
|
-
{
|
|
203
|
-
context: {
|
|
204
|
-
key: 'value',
|
|
205
|
-
label: 'value',
|
|
206
|
-
value: 'test'
|
|
207
|
-
},
|
|
208
|
-
message: 'There is no definition found for "test" in name field: "ASSET-GROUP, ASSET"',
|
|
209
|
-
path: ['value'],
|
|
210
|
-
type: 'any.custom'
|
|
211
|
-
}
|
|
212
|
-
]);
|
|
213
|
-
});
|
|
180
|
+
test('valid data', () => {
|
|
181
|
+
let rawDefinition = getSimpleRawDefinition('test');
|
|
182
|
+
let validators = joi_custom_validators_1.JoiCustomValidators;
|
|
183
|
+
validators.getDefinitionNames(DefinitionType).add('test');
|
|
184
|
+
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
185
|
+
abortEarly: false,
|
|
186
|
+
context: rawDefinition
|
|
187
|
+
});
|
|
188
|
+
expect(value).toEqual({ value: 'assetTest' });
|
|
189
|
+
expect(error).toEqual(undefined);
|
|
190
|
+
});
|
|
191
|
+
test('multiple reference', () => {
|
|
192
|
+
let rawDefinition = getSimpleRawDefinition('test');
|
|
193
|
+
let validators = joi_custom_validators_1.JoiCustomValidators;
|
|
194
|
+
validators.getDefinitionNames(DefinitionType).add('test');
|
|
195
|
+
let { value, error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
196
|
+
abortEarly: false,
|
|
197
|
+
context: rawDefinition
|
|
198
|
+
});
|
|
199
|
+
expect(value).toEqual({ value: 'assetTest' });
|
|
200
|
+
expect(error).toEqual(undefined);
|
|
201
|
+
});
|
|
202
|
+
test('primitive valid data', () => {
|
|
203
|
+
let rawDefinition = getFlatRawDefinition('test');
|
|
204
|
+
let primitiveSchema = Joi.string().reference(Asset).required();
|
|
205
|
+
let validators = joi_custom_validators_1.JoiCustomValidators;
|
|
206
|
+
validators.getDefinitionNames(DefinitionType).add('test');
|
|
207
|
+
let { value, error } = primitiveSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
208
|
+
abortEarly: false,
|
|
209
|
+
context: rawDefinition
|
|
210
|
+
});
|
|
211
|
+
expect(value).toEqual('assetTest');
|
|
212
|
+
expect(error).toEqual(undefined);
|
|
213
|
+
});
|
|
214
|
+
test('should detect non existing references', () => {
|
|
215
|
+
let rawDefinition = getSimpleRawDefinition('test');
|
|
216
|
+
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
217
|
+
abortEarly: false,
|
|
218
|
+
context: rawDefinition
|
|
219
|
+
});
|
|
220
|
+
expect(error?.details).toEqual([
|
|
221
|
+
{
|
|
222
|
+
context: {
|
|
223
|
+
key: 'value',
|
|
224
|
+
label: 'value',
|
|
225
|
+
value: 'test'
|
|
226
|
+
},
|
|
227
|
+
message: 'There is no definition found for "test" in name field: "ASSET"',
|
|
228
|
+
path: ['value'],
|
|
229
|
+
type: 'any.custom'
|
|
230
|
+
}
|
|
231
|
+
]);
|
|
214
232
|
});
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
233
|
+
test('should detect non existing multiple references', () => {
|
|
234
|
+
let rawDefinition = getSimpleRawDefinition('test');
|
|
235
|
+
let { error } = multipleSchema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
236
|
+
abortEarly: false,
|
|
237
|
+
context: rawDefinition
|
|
238
|
+
});
|
|
239
|
+
expect(error?.details).toEqual([
|
|
240
|
+
{
|
|
241
|
+
context: {
|
|
242
|
+
key: 'value',
|
|
243
|
+
label: 'value',
|
|
244
|
+
value: 'test'
|
|
245
|
+
},
|
|
246
|
+
message: 'There is no definition found for "test" in name field: "ASSET-GROUP, ASSET"',
|
|
247
|
+
path: ['value'],
|
|
248
|
+
type: 'any.custom'
|
|
249
|
+
}
|
|
250
|
+
]);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
describe('Path', () => {
|
|
254
|
+
let schema = Joi.object().keys({
|
|
255
|
+
value: Joi.string().path().required()
|
|
256
|
+
});
|
|
257
|
+
test('valid data', () => {
|
|
258
|
+
let rawDefinition = getSimpleRawDefinition('images/test.png');
|
|
259
|
+
let { value, error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
260
|
+
abortEarly: false,
|
|
261
|
+
context: rawDefinition
|
|
262
|
+
});
|
|
263
|
+
expect(value).toEqual({ value: '.test/images/test.png' });
|
|
264
|
+
expect(error).toEqual(undefined);
|
|
265
|
+
});
|
|
266
|
+
test('should detect files not existing', () => {
|
|
267
|
+
let rawDefinition = getSimpleRawDefinition('invalid data');
|
|
268
|
+
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
269
|
+
abortEarly: false,
|
|
270
|
+
context: rawDefinition
|
|
271
|
+
});
|
|
272
|
+
expect(error?.details).toStrictEqual([
|
|
273
|
+
{
|
|
274
|
+
message: '"value" with value "invalid data" fails to match the required pattern: /^[\\S]+$/',
|
|
275
|
+
path: ['value'],
|
|
276
|
+
type: 'string.pattern.base',
|
|
277
|
+
context: {
|
|
278
|
+
name: undefined,
|
|
279
|
+
regex: /^[\S]+$/,
|
|
280
|
+
value: 'invalid data',
|
|
281
|
+
label: 'value',
|
|
282
|
+
key: 'value'
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
]);
|
|
286
|
+
});
|
|
287
|
+
test('should detect files not existing', () => {
|
|
288
|
+
let rawDefinition = getSimpleRawDefinition('false/path.png');
|
|
289
|
+
let { error } = schema.validate(raw_definition_helper_1.RawDefinitionHelper.flatten(rawDefinition), {
|
|
290
|
+
abortEarly: false,
|
|
291
|
+
context: rawDefinition
|
|
292
|
+
});
|
|
293
|
+
expect(error?.details).toStrictEqual([
|
|
294
|
+
{
|
|
295
|
+
message: 'No file is found in the path: "false/path.png"',
|
|
296
|
+
path: ['value'],
|
|
297
|
+
type: 'any.custom',
|
|
298
|
+
context: { label: 'value', value: 'false/path.png', key: 'value' }
|
|
299
|
+
}
|
|
300
|
+
]);
|
|
258
301
|
});
|
|
302
|
+
});
|
|
259
303
|
});
|
|
260
|
-
//# sourceMappingURL=joi-custom-validators.spec.js.map
|
|
304
|
+
//# sourceMappingURL=joi-custom-validators.spec.js.map
|