@e22m4u/js-repository 0.4.0 → 0.5.0
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/README.md +479 -61
- package/dist/cjs/index.cjs +319 -270
- package/package.json +1 -1
- package/src/adapter/adapter-loader.js +1 -1
- package/src/adapter/adapter-loader.spec.js +1 -1
- package/src/adapter/decorator/data-sanitizing-decorator.js +1 -1
- package/src/adapter/decorator/data-transformation-decorator.js +1 -1
- package/src/adapter/decorator/data-validation-decorator.js +1 -1
- package/src/adapter/decorator/default-values-decorator.js +1 -1
- package/src/adapter/decorator/fields-filtering-decorator.js +1 -1
- package/src/adapter/decorator/inclusion-decorator.js +1 -1
- package/src/adapter/decorator/property-uniqueness-decorator.js +1 -1
- package/src/definition/datasource/datasource-definition-validator.js +3 -3
- package/src/definition/datasource/datasource-definition-validator.spec.js +3 -3
- package/src/definition/model/model-data-sanitizer.js +2 -2
- package/src/definition/model/model-data-transformer.js +71 -13
- package/src/definition/model/model-data-transformer.spec.js +2073 -407
- package/src/definition/model/model-data-validator.js +125 -37
- package/src/definition/model/model-data-validator.spec.js +2138 -440
- package/src/definition/model/model-definition-utils.js +5 -5
- package/src/definition/model/model-definition-utils.spec.js +7 -7
- package/src/definition/model/model-definition-validator.js +7 -7
- package/src/definition/model/model-definition-validator.spec.js +10 -7
- package/src/definition/model/properties/properties-definition-validator.js +129 -54
- package/src/definition/model/properties/properties-definition-validator.spec.js +85 -25
- package/src/definition/model/properties/property-transformer/builtin/index.d.ts +0 -1
- package/src/definition/model/properties/property-transformer/builtin/index.js +0 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.d.ts +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-lower-case-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.d.ts +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/to-upper-case-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.js +1 -1
- package/src/definition/model/properties/property-transformer/builtin/trim-transformer.spec.js +1 -1
- package/src/definition/model/properties/property-transformer/property-transformer-registry.js +2 -4
- package/src/definition/model/properties/property-transformer/property-transformer-registry.spec.js +2 -4
- package/src/definition/model/properties/property-transformer/property-transformer.d.ts +2 -2
- package/src/definition/model/properties/property-uniqueness-validator.js +4 -4
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +4 -4
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/max-length-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/min-length-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.d.ts +1 -1
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.js +2 -2
- package/src/definition/model/properties/property-validator/builtin/regexp-validator.spec.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator-registry.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator-registry.spec.js +2 -2
- package/src/definition/model/properties/property-validator/property-validator.d.ts +2 -2
- package/src/definition/model/relations/relations-definition-validator.js +23 -23
- package/src/definition/model/relations/relations-definition-validator.spec.js +24 -24
- package/src/errors/invalid-operator-value-error.js +1 -1
- package/src/errors/invalid-operator-value-error.spec.js +1 -1
- package/src/filter/fields-clause-tool.js +5 -5
- package/src/filter/fields-clause-tool.spec.js +16 -16
- package/src/filter/include-clause-tool.js +6 -6
- package/src/filter/include-clause-tool.spec.js +2 -2
- package/src/filter/operator-clause-tool.js +13 -13
- package/src/filter/operator-clause-tool.spec.js +13 -13
- package/src/filter/order-clause-tool.js +3 -3
- package/src/filter/order-clause-tool.spec.js +4 -4
- package/src/filter/slice-clause-tool.js +5 -5
- package/src/filter/slice-clause-tool.spec.js +5 -5
- package/src/filter/where-clause-tool.js +4 -4
- package/src/filter/where-clause-tool.spec.js +3 -3
- package/src/relations/belongs-to-resolver.js +14 -14
- package/src/relations/belongs-to-resolver.spec.js +14 -14
- package/src/relations/has-many-resolver.js +22 -22
- package/src/relations/has-many-resolver.spec.js +23 -23
- package/src/relations/has-one-resolver.js +22 -22
- package/src/relations/has-one-resolver.spec.js +23 -23
- package/src/relations/references-many-resolver.js +7 -7
- package/src/relations/references-many-resolver.spec.js +7 -7
- package/src/repository/repository-registry.js +1 -1
- package/src/utils/exclude-object-keys.js +1 -1
- package/src/utils/exclude-object-keys.spec.js +1 -1
- package/src/utils/model-name-to-model-key.js +1 -1
- package/src/utils/model-name-to-model-key.spec.js +7 -7
- package/src/utils/select-object-keys.js +3 -3
- package/src/utils/select-object-keys.spec.js +3 -3
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.d.ts +0 -6
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.js +0 -22
- package/src/definition/model/properties/property-transformer/builtin/to-title-case-transformer.spec.js +0 -41
|
@@ -30,7 +30,7 @@ export class PropertyValidatorRegistry extends Service {
|
|
|
30
30
|
if (!name || typeof name !== 'string')
|
|
31
31
|
throw new InvalidArgumentError(
|
|
32
32
|
'A name of the property validator must ' +
|
|
33
|
-
'be a non-empty String, but %v given.',
|
|
33
|
+
'be a non-empty String, but %v was given.',
|
|
34
34
|
name,
|
|
35
35
|
);
|
|
36
36
|
if (name in this._validators)
|
|
@@ -40,7 +40,7 @@ export class PropertyValidatorRegistry extends Service {
|
|
|
40
40
|
);
|
|
41
41
|
if (typeof validator !== 'function')
|
|
42
42
|
throw new InvalidArgumentError(
|
|
43
|
-
'The property validator %v must be a Function, but %v given.',
|
|
43
|
+
'The property validator %v must be a Function, but %v was given.',
|
|
44
44
|
name,
|
|
45
45
|
validator,
|
|
46
46
|
);
|
package/src/definition/model/properties/property-validator/property-validator-registry.spec.js
CHANGED
|
@@ -30,7 +30,7 @@ describe('PropertyValidatorRegistry', function () {
|
|
|
30
30
|
const error = v =>
|
|
31
31
|
format(
|
|
32
32
|
'A name of the property validator must ' +
|
|
33
|
-
'be a non-empty String, but %s given.',
|
|
33
|
+
'be a non-empty String, but %s was given.',
|
|
34
34
|
v,
|
|
35
35
|
);
|
|
36
36
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -59,7 +59,7 @@ describe('PropertyValidatorRegistry', function () {
|
|
|
59
59
|
const throwable = v => () => pvr.addValidator('test', v);
|
|
60
60
|
const error = v =>
|
|
61
61
|
format(
|
|
62
|
-
'The property validator "test" must be a Function, but %s given.',
|
|
62
|
+
'The property validator "test" must be a Function, but %s was given.',
|
|
63
63
|
v,
|
|
64
64
|
);
|
|
65
65
|
expect(throwable('str')).to.throw(error('"str"'));
|
|
@@ -17,13 +17,13 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
17
17
|
if (!modelName || typeof modelName !== 'string')
|
|
18
18
|
throw new InvalidArgumentError(
|
|
19
19
|
'The first argument of RelationsDefinitionValidator.validate ' +
|
|
20
|
-
'should be a non-empty String, but %v given.',
|
|
20
|
+
'should be a non-empty String, but %v was given.',
|
|
21
21
|
modelName,
|
|
22
22
|
);
|
|
23
23
|
if (!relDefs || typeof relDefs !== 'object' || Array.isArray(relDefs))
|
|
24
24
|
throw new InvalidArgumentError(
|
|
25
25
|
'The provided option "relations" of the model %v ' +
|
|
26
|
-
'should be an Object, but %v given.',
|
|
26
|
+
'should be an Object, but %v was given.',
|
|
27
27
|
modelName,
|
|
28
28
|
relDefs,
|
|
29
29
|
);
|
|
@@ -45,19 +45,19 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
45
45
|
if (!modelName || typeof modelName !== 'string')
|
|
46
46
|
throw new InvalidArgumentError(
|
|
47
47
|
'The first argument of RelationsDefinitionValidator._validateRelation ' +
|
|
48
|
-
'should be a non-empty String, but %v given.',
|
|
48
|
+
'should be a non-empty String, but %v was given.',
|
|
49
49
|
modelName,
|
|
50
50
|
);
|
|
51
51
|
if (!relName || typeof relName !== 'string')
|
|
52
52
|
throw new InvalidArgumentError(
|
|
53
53
|
'The relation name of the model %v should be ' +
|
|
54
|
-
'a non-empty String, but %v given.',
|
|
54
|
+
'a non-empty String, but %v was given.',
|
|
55
55
|
modelName,
|
|
56
56
|
relName,
|
|
57
57
|
);
|
|
58
58
|
if (!relDef || typeof relDef !== 'object' || Array.isArray(relDef))
|
|
59
59
|
throw new InvalidArgumentError(
|
|
60
|
-
'The relation %v of the model %v should be an Object, but %v given.',
|
|
60
|
+
'The relation %v of the model %v should be an Object, but %v was given.',
|
|
61
61
|
relName,
|
|
62
62
|
modelName,
|
|
63
63
|
relDef,
|
|
@@ -65,7 +65,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
65
65
|
if (!relDef.type || !Object.values(Type).includes(relDef.type))
|
|
66
66
|
throw new InvalidArgumentError(
|
|
67
67
|
'The relation %v of the model %v requires the option "type" ' +
|
|
68
|
-
'to have one of relation types: %l, but %v given.',
|
|
68
|
+
'to have one of relation types: %l, but %v was given.',
|
|
69
69
|
relName,
|
|
70
70
|
modelName,
|
|
71
71
|
Object.values(Type),
|
|
@@ -112,7 +112,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
112
112
|
throw new InvalidArgumentError(
|
|
113
113
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
114
114
|
'so it expects the option "polymorphic" to be a Boolean, ' +
|
|
115
|
-
'but %v given.',
|
|
115
|
+
'but %v was given.',
|
|
116
116
|
relName,
|
|
117
117
|
modelName,
|
|
118
118
|
relDef.polymorphic,
|
|
@@ -121,7 +121,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
121
121
|
throw new InvalidArgumentError(
|
|
122
122
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, ' +
|
|
123
123
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
124
|
-
'but %v given.',
|
|
124
|
+
'but %v was given.',
|
|
125
125
|
relName,
|
|
126
126
|
modelName,
|
|
127
127
|
relDef.foreignKey,
|
|
@@ -130,7 +130,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
130
130
|
throw new InvalidArgumentError(
|
|
131
131
|
'The relation %v of the model %v is a polymorphic "belongsTo" relation, ' +
|
|
132
132
|
'so it expects the provided option "discriminator" to be a String, ' +
|
|
133
|
-
'but %v given.',
|
|
133
|
+
'but %v was given.',
|
|
134
134
|
relName,
|
|
135
135
|
modelName,
|
|
136
136
|
relDef.discriminator,
|
|
@@ -141,7 +141,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
141
141
|
throw new InvalidArgumentError(
|
|
142
142
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
143
143
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
144
|
-
'but %v given.',
|
|
144
|
+
'but %v was given.',
|
|
145
145
|
relName,
|
|
146
146
|
modelName,
|
|
147
147
|
relDef.model,
|
|
@@ -150,7 +150,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
150
150
|
throw new InvalidArgumentError(
|
|
151
151
|
'The relation %v of the model %v has the type "belongsTo", ' +
|
|
152
152
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
153
|
-
'but %v given.',
|
|
153
|
+
'but %v was given.',
|
|
154
154
|
relName,
|
|
155
155
|
modelName,
|
|
156
156
|
relDef.foreignKey,
|
|
@@ -208,7 +208,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
208
208
|
throw new InvalidArgumentError(
|
|
209
209
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
210
210
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
211
|
-
'but %v given.',
|
|
211
|
+
'but %v was given.',
|
|
212
212
|
relName,
|
|
213
213
|
modelName,
|
|
214
214
|
relDef.model,
|
|
@@ -238,7 +238,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
238
238
|
throw new InvalidArgumentError(
|
|
239
239
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
240
240
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
241
|
-
'to be a non-empty String, but %v given.',
|
|
241
|
+
'to be a non-empty String, but %v was given.',
|
|
242
242
|
relName,
|
|
243
243
|
modelName,
|
|
244
244
|
relDef.foreignKey,
|
|
@@ -247,7 +247,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
247
247
|
throw new InvalidArgumentError(
|
|
248
248
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
249
249
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
250
|
-
'to be a non-empty String, but %v given.',
|
|
250
|
+
'to be a non-empty String, but %v was given.',
|
|
251
251
|
relName,
|
|
252
252
|
modelName,
|
|
253
253
|
relDef.discriminator,
|
|
@@ -256,7 +256,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
256
256
|
throw new InvalidArgumentError(
|
|
257
257
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
258
258
|
'so it expects the provided option "polymorphic" to be ' +
|
|
259
|
-
'a String or a Boolean, but %v given.',
|
|
259
|
+
'a String or a Boolean, but %v was given.',
|
|
260
260
|
relName,
|
|
261
261
|
modelName,
|
|
262
262
|
relDef.polymorphic,
|
|
@@ -268,7 +268,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
268
268
|
throw new InvalidArgumentError(
|
|
269
269
|
'The relation %v of the model %v has the type "hasOne", ' +
|
|
270
270
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
271
|
-
'but %v given.',
|
|
271
|
+
'but %v was given.',
|
|
272
272
|
relName,
|
|
273
273
|
modelName,
|
|
274
274
|
relDef.foreignKey,
|
|
@@ -326,7 +326,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
326
326
|
throw new InvalidArgumentError(
|
|
327
327
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
328
328
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
329
|
-
'but %v given.',
|
|
329
|
+
'but %v was given.',
|
|
330
330
|
relName,
|
|
331
331
|
modelName,
|
|
332
332
|
relDef.model,
|
|
@@ -356,7 +356,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
356
356
|
throw new InvalidArgumentError(
|
|
357
357
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
358
358
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
359
|
-
'to be a non-empty String, but %v given.',
|
|
359
|
+
'to be a non-empty String, but %v was given.',
|
|
360
360
|
relName,
|
|
361
361
|
modelName,
|
|
362
362
|
relDef.foreignKey,
|
|
@@ -365,7 +365,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
365
365
|
throw new InvalidArgumentError(
|
|
366
366
|
'The relation %v of the model %v has the option "polymorphic" ' +
|
|
367
367
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
368
|
-
'to be a non-empty String, but %v given.',
|
|
368
|
+
'to be a non-empty String, but %v was given.',
|
|
369
369
|
relName,
|
|
370
370
|
modelName,
|
|
371
371
|
relDef.discriminator,
|
|
@@ -374,7 +374,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
374
374
|
throw new InvalidArgumentError(
|
|
375
375
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
376
376
|
'so it expects the provided option "polymorphic" to be ' +
|
|
377
|
-
'a String or a Boolean, but %v given.',
|
|
377
|
+
'a String or a Boolean, but %v was given.',
|
|
378
378
|
relName,
|
|
379
379
|
modelName,
|
|
380
380
|
relDef.polymorphic,
|
|
@@ -386,7 +386,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
386
386
|
throw new InvalidArgumentError(
|
|
387
387
|
'The relation %v of the model %v has the type "hasMany", ' +
|
|
388
388
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
389
|
-
'but %v given.',
|
|
389
|
+
'but %v was given.',
|
|
390
390
|
relName,
|
|
391
391
|
modelName,
|
|
392
392
|
relDef.foreignKey,
|
|
@@ -424,7 +424,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
424
424
|
throw new InvalidArgumentError(
|
|
425
425
|
'The relation %v of the model %v has the type "referencesMany", ' +
|
|
426
426
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
427
|
-
'but %v given.',
|
|
427
|
+
'but %v was given.',
|
|
428
428
|
relName,
|
|
429
429
|
modelName,
|
|
430
430
|
relDef.model,
|
|
@@ -433,7 +433,7 @@ export class RelationsDefinitionValidator extends Service {
|
|
|
433
433
|
throw new InvalidArgumentError(
|
|
434
434
|
'The relation %v of the model %v has the type "referencesMany", ' +
|
|
435
435
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
436
|
-
'but %v given.',
|
|
436
|
+
'but %v was given.',
|
|
437
437
|
relName,
|
|
438
438
|
modelName,
|
|
439
439
|
relDef.foreignKey,
|
|
@@ -12,7 +12,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
12
12
|
const error = v =>
|
|
13
13
|
format(
|
|
14
14
|
'The first argument of RelationsDefinitionValidator.validate ' +
|
|
15
|
-
'should be a non-empty String, but %s given.',
|
|
15
|
+
'should be a non-empty String, but %s was given.',
|
|
16
16
|
v,
|
|
17
17
|
);
|
|
18
18
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -31,7 +31,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
31
31
|
const error = v =>
|
|
32
32
|
format(
|
|
33
33
|
'The provided option "relations" of the model "model" ' +
|
|
34
|
-
'should be an Object, but %s given.',
|
|
34
|
+
'should be an Object, but %s was given.',
|
|
35
35
|
v,
|
|
36
36
|
);
|
|
37
37
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -49,7 +49,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
49
49
|
const error = v =>
|
|
50
50
|
format(
|
|
51
51
|
'The relation name of the model "model" should be ' +
|
|
52
|
-
'a non-empty String, but %s given.',
|
|
52
|
+
'a non-empty String, but %s was given.',
|
|
53
53
|
v,
|
|
54
54
|
);
|
|
55
55
|
expect(validate({['']: {}})).to.throw(error('""'));
|
|
@@ -61,7 +61,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
61
61
|
const error = v =>
|
|
62
62
|
format(
|
|
63
63
|
'The relation "foo" of the model "model" should ' +
|
|
64
|
-
'be an Object, but %s given.',
|
|
64
|
+
'be an Object, but %s was given.',
|
|
65
65
|
v,
|
|
66
66
|
);
|
|
67
67
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -82,7 +82,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
82
82
|
const error = v =>
|
|
83
83
|
format(
|
|
84
84
|
'The relation "foo" of the model "model" requires the option "type" ' +
|
|
85
|
-
'to have one of relation types: %l, but %s given.',
|
|
85
|
+
'to have one of relation types: %l, but %s was given.',
|
|
86
86
|
Object.values(RelationType),
|
|
87
87
|
v,
|
|
88
88
|
);
|
|
@@ -111,7 +111,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
111
111
|
format(
|
|
112
112
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
113
113
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
114
|
-
'but %s given.',
|
|
114
|
+
'but %s was given.',
|
|
115
115
|
v,
|
|
116
116
|
);
|
|
117
117
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -138,7 +138,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
138
138
|
format(
|
|
139
139
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
140
140
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
141
|
-
'but %s given.',
|
|
141
|
+
'but %s was given.',
|
|
142
142
|
v,
|
|
143
143
|
);
|
|
144
144
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -181,7 +181,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
181
181
|
format(
|
|
182
182
|
'The relation "foo" of the model "model" has the type "belongsTo", ' +
|
|
183
183
|
'so it expects the option "polymorphic" to be a Boolean, ' +
|
|
184
|
-
'but %s given.',
|
|
184
|
+
'but %s was given.',
|
|
185
185
|
v,
|
|
186
186
|
);
|
|
187
187
|
expect(validate('str')).to.throw(error('"str"'));
|
|
@@ -204,7 +204,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
204
204
|
format(
|
|
205
205
|
'The relation "foo" of the model "model" is a polymorphic "belongsTo" relation, ' +
|
|
206
206
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
207
|
-
'but %s given.',
|
|
207
|
+
'but %s was given.',
|
|
208
208
|
v,
|
|
209
209
|
);
|
|
210
210
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -231,7 +231,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
231
231
|
format(
|
|
232
232
|
'The relation "foo" of the model "model" is a polymorphic "belongsTo" relation, ' +
|
|
233
233
|
'so it expects the provided option "discriminator" to be a String, ' +
|
|
234
|
-
'but %s given.',
|
|
234
|
+
'but %s was given.',
|
|
235
235
|
v,
|
|
236
236
|
);
|
|
237
237
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -262,7 +262,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
262
262
|
format(
|
|
263
263
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
264
264
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
265
|
-
'but %s given.',
|
|
265
|
+
'but %s was given.',
|
|
266
266
|
v,
|
|
267
267
|
);
|
|
268
268
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -289,7 +289,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
289
289
|
format(
|
|
290
290
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
291
291
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
292
|
-
'but %s given.',
|
|
292
|
+
'but %s was given.',
|
|
293
293
|
v,
|
|
294
294
|
);
|
|
295
295
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -334,7 +334,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
334
334
|
format(
|
|
335
335
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
336
336
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
337
|
-
'but %s given.',
|
|
337
|
+
'but %s was given.',
|
|
338
338
|
v,
|
|
339
339
|
);
|
|
340
340
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -399,7 +399,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
399
399
|
format(
|
|
400
400
|
'The relation "foo" of the model "model" has the type "hasOne", ' +
|
|
401
401
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
402
|
-
'but %s given.',
|
|
402
|
+
'but %s was given.',
|
|
403
403
|
v,
|
|
404
404
|
);
|
|
405
405
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -428,7 +428,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
428
428
|
format(
|
|
429
429
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
430
430
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
431
|
-
'to be a non-empty String, but %s given.',
|
|
431
|
+
'to be a non-empty String, but %s was given.',
|
|
432
432
|
v,
|
|
433
433
|
);
|
|
434
434
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -457,7 +457,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
457
457
|
format(
|
|
458
458
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
459
459
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
460
|
-
'to be a non-empty String, but %s given.',
|
|
460
|
+
'to be a non-empty String, but %s was given.',
|
|
461
461
|
v,
|
|
462
462
|
);
|
|
463
463
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -488,7 +488,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
488
488
|
format(
|
|
489
489
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
490
490
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
491
|
-
'but %s given.',
|
|
491
|
+
'but %s was given.',
|
|
492
492
|
v,
|
|
493
493
|
);
|
|
494
494
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -515,7 +515,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
515
515
|
format(
|
|
516
516
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
517
517
|
'so it requires the option "foreignKey" to be a non-empty String, ' +
|
|
518
|
-
'but %s given.',
|
|
518
|
+
'but %s was given.',
|
|
519
519
|
v,
|
|
520
520
|
);
|
|
521
521
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -560,7 +560,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
560
560
|
format(
|
|
561
561
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
562
562
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
563
|
-
'but %s given.',
|
|
563
|
+
'but %s was given.',
|
|
564
564
|
v,
|
|
565
565
|
);
|
|
566
566
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -625,7 +625,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
625
625
|
format(
|
|
626
626
|
'The relation "foo" of the model "model" has the type "hasMany", ' +
|
|
627
627
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
628
|
-
'but %s given.',
|
|
628
|
+
'but %s was given.',
|
|
629
629
|
v,
|
|
630
630
|
);
|
|
631
631
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -654,7 +654,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
654
654
|
format(
|
|
655
655
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
656
656
|
'with "true" value, so it requires the option "foreignKey" ' +
|
|
657
|
-
'to be a non-empty String, but %s given.',
|
|
657
|
+
'to be a non-empty String, but %s was given.',
|
|
658
658
|
v,
|
|
659
659
|
);
|
|
660
660
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -683,7 +683,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
683
683
|
format(
|
|
684
684
|
'The relation "foo" of the model "model" has the option "polymorphic" ' +
|
|
685
685
|
'with "true" value, so it requires the option "discriminator" ' +
|
|
686
|
-
'to be a non-empty String, but %s given.',
|
|
686
|
+
'to be a non-empty String, but %s was given.',
|
|
687
687
|
v,
|
|
688
688
|
);
|
|
689
689
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -712,7 +712,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
712
712
|
format(
|
|
713
713
|
'The relation "foo" of the model "model" has the type "referencesMany", ' +
|
|
714
714
|
'so it requires the option "model" to be a non-empty String, ' +
|
|
715
|
-
'but %s given.',
|
|
715
|
+
'but %s was given.',
|
|
716
716
|
v,
|
|
717
717
|
);
|
|
718
718
|
expect(validate('')).to.throw(error('""'));
|
|
@@ -739,7 +739,7 @@ describe('RelationsDefinitionValidator', function () {
|
|
|
739
739
|
format(
|
|
740
740
|
'The relation "foo" of the model "model" has the type "referencesMany", ' +
|
|
741
741
|
'so it expects the provided option "foreignKey" to be a String, ' +
|
|
742
|
-
'but %s given.',
|
|
742
|
+
'but %s was given.',
|
|
743
743
|
v,
|
|
744
744
|
);
|
|
745
745
|
expect(validate(10)).to.throw(error('10'));
|
|
@@ -14,7 +14,7 @@ export class InvalidOperatorValueError extends Error {
|
|
|
14
14
|
constructor(operator, expected, value) {
|
|
15
15
|
super(
|
|
16
16
|
format(
|
|
17
|
-
'Condition of {%s: ...} should have %s, but %v given.',
|
|
17
|
+
'Condition of {%s: ...} should have %s, but %v was given.',
|
|
18
18
|
operator,
|
|
19
19
|
expected,
|
|
20
20
|
value,
|
|
@@ -5,7 +5,7 @@ describe('InvalidOperatorValueError', function () {
|
|
|
5
5
|
it('sets specific message', function () {
|
|
6
6
|
const error = new InvalidOperatorValueError('exists', 'a boolean', '');
|
|
7
7
|
const message =
|
|
8
|
-
'Condition of {exists: ...} should have a boolean, but "" given.';
|
|
8
|
+
'Condition of {exists: ...} should have a boolean, but "" was given.';
|
|
9
9
|
expect(error.message).to.be.eq(message);
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -22,7 +22,7 @@ export class FieldsClauseTool extends Service {
|
|
|
22
22
|
if (!entity || typeof entity !== 'object' || Array.isArray(entity))
|
|
23
23
|
throw new InvalidArgumentError(
|
|
24
24
|
'The first argument of FieldsClauseTool.filter should be an Object or ' +
|
|
25
|
-
'an Array of Object, but %v given.',
|
|
25
|
+
'an Array of Object, but %v was given.',
|
|
26
26
|
entity,
|
|
27
27
|
);
|
|
28
28
|
});
|
|
@@ -30,7 +30,7 @@ export class FieldsClauseTool extends Service {
|
|
|
30
30
|
if (!modelName || typeof modelName !== 'string')
|
|
31
31
|
throw new InvalidArgumentError(
|
|
32
32
|
'The second argument of FieldsClauseTool.filter should be ' +
|
|
33
|
-
'a non-empty String, but %v given.',
|
|
33
|
+
'a non-empty String, but %v was given.',
|
|
34
34
|
modelName,
|
|
35
35
|
);
|
|
36
36
|
|
|
@@ -42,7 +42,7 @@ export class FieldsClauseTool extends Service {
|
|
|
42
42
|
if (!field || typeof field !== 'string')
|
|
43
43
|
throw new InvalidArgumentError(
|
|
44
44
|
'The provided option "fields" should be a non-empty String ' +
|
|
45
|
-
'or an Array of non-empty String, but %v given.',
|
|
45
|
+
'or an Array of non-empty String, but %v was given.',
|
|
46
46
|
field,
|
|
47
47
|
);
|
|
48
48
|
});
|
|
@@ -70,7 +70,7 @@ export class FieldsClauseTool extends Service {
|
|
|
70
70
|
if (!field || typeof field !== 'string')
|
|
71
71
|
throw new InvalidArgumentError(
|
|
72
72
|
'The provided option "fields" should be a non-empty String ' +
|
|
73
|
-
'or an Array of non-empty String, but %v given.',
|
|
73
|
+
'or an Array of non-empty String, but %v was given.',
|
|
74
74
|
field,
|
|
75
75
|
);
|
|
76
76
|
});
|
|
@@ -90,7 +90,7 @@ export class FieldsClauseTool extends Service {
|
|
|
90
90
|
if (!field || typeof field !== 'string')
|
|
91
91
|
throw new InvalidArgumentError(
|
|
92
92
|
'The provided option "fields" should be a non-empty String ' +
|
|
93
|
-
'or an Array of non-empty String, but %v given.',
|
|
93
|
+
'or an Array of non-empty String, but %v was given.',
|
|
94
94
|
field,
|
|
95
95
|
);
|
|
96
96
|
});
|
|
@@ -24,7 +24,7 @@ describe('FieldsClauseTool', function () {
|
|
|
24
24
|
const error = v =>
|
|
25
25
|
format(
|
|
26
26
|
'The first argument of FieldsClauseTool.filter should be an Object or ' +
|
|
27
|
-
'an Array of Object, but %s given.',
|
|
27
|
+
'an Array of Object, but %s was given.',
|
|
28
28
|
v,
|
|
29
29
|
);
|
|
30
30
|
expect(throwable('str')).to.throw(error('"str"'));
|
|
@@ -45,7 +45,7 @@ describe('FieldsClauseTool', function () {
|
|
|
45
45
|
const error = v =>
|
|
46
46
|
format(
|
|
47
47
|
'The second argument of FieldsClauseTool.filter should be ' +
|
|
48
|
-
'a non-empty String, but %s given.',
|
|
48
|
+
'a non-empty String, but %s was given.',
|
|
49
49
|
v,
|
|
50
50
|
);
|
|
51
51
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -64,7 +64,7 @@ describe('FieldsClauseTool', function () {
|
|
|
64
64
|
const error = v =>
|
|
65
65
|
format(
|
|
66
66
|
'The provided option "fields" should be a non-empty String ' +
|
|
67
|
-
'or an Array of non-empty String, but %s given.',
|
|
67
|
+
'or an Array of non-empty String, but %s was given.',
|
|
68
68
|
v,
|
|
69
69
|
);
|
|
70
70
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -103,7 +103,7 @@ describe('FieldsClauseTool', function () {
|
|
|
103
103
|
const error = v =>
|
|
104
104
|
format(
|
|
105
105
|
'The first argument of FieldsClauseTool.filter should be an Object or ' +
|
|
106
|
-
'an Array of Object, but %s given.',
|
|
106
|
+
'an Array of Object, but %s was given.',
|
|
107
107
|
v,
|
|
108
108
|
);
|
|
109
109
|
expect(throwable('str')).to.throw(error('"str"'));
|
|
@@ -124,7 +124,7 @@ describe('FieldsClauseTool', function () {
|
|
|
124
124
|
const error = v =>
|
|
125
125
|
format(
|
|
126
126
|
'The second argument of FieldsClauseTool.filter should be ' +
|
|
127
|
-
'a non-empty String, but %s given.',
|
|
127
|
+
'a non-empty String, but %s was given.',
|
|
128
128
|
v,
|
|
129
129
|
);
|
|
130
130
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -143,7 +143,7 @@ describe('FieldsClauseTool', function () {
|
|
|
143
143
|
const error = v =>
|
|
144
144
|
format(
|
|
145
145
|
'The provided option "fields" should be a non-empty String ' +
|
|
146
|
-
'or an Array of non-empty String, but %s given.',
|
|
146
|
+
'or an Array of non-empty String, but %s was given.',
|
|
147
147
|
v,
|
|
148
148
|
);
|
|
149
149
|
expect(throwable([''])).to.throw(error('""'));
|
|
@@ -189,7 +189,7 @@ describe('FieldsClauseTool', function () {
|
|
|
189
189
|
const error = v =>
|
|
190
190
|
format(
|
|
191
191
|
'The first argument of FieldsClauseTool.filter should be an Object or ' +
|
|
192
|
-
'an Array of Object, but %s given.',
|
|
192
|
+
'an Array of Object, but %s was given.',
|
|
193
193
|
v,
|
|
194
194
|
);
|
|
195
195
|
expect(throwable(['str'])).to.throw(error('"str"'));
|
|
@@ -216,7 +216,7 @@ describe('FieldsClauseTool', function () {
|
|
|
216
216
|
const error = v =>
|
|
217
217
|
format(
|
|
218
218
|
'The second argument of FieldsClauseTool.filter should be ' +
|
|
219
|
-
'a non-empty String, but %s given.',
|
|
219
|
+
'a non-empty String, but %s was given.',
|
|
220
220
|
v,
|
|
221
221
|
);
|
|
222
222
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -243,7 +243,7 @@ describe('FieldsClauseTool', function () {
|
|
|
243
243
|
const error = v =>
|
|
244
244
|
format(
|
|
245
245
|
'The provided option "fields" should be a non-empty String ' +
|
|
246
|
-
'or an Array of non-empty String, but %s given.',
|
|
246
|
+
'or an Array of non-empty String, but %s was given.',
|
|
247
247
|
v,
|
|
248
248
|
);
|
|
249
249
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -306,7 +306,7 @@ describe('FieldsClauseTool', function () {
|
|
|
306
306
|
const error = v =>
|
|
307
307
|
format(
|
|
308
308
|
'The first argument of FieldsClauseTool.filter should be an Object or ' +
|
|
309
|
-
'an Array of Object, but %s given.',
|
|
309
|
+
'an Array of Object, but %s was given.',
|
|
310
310
|
v,
|
|
311
311
|
);
|
|
312
312
|
expect(throwable(['str'])).to.throw(error('"str"'));
|
|
@@ -333,7 +333,7 @@ describe('FieldsClauseTool', function () {
|
|
|
333
333
|
const error = v =>
|
|
334
334
|
format(
|
|
335
335
|
'The second argument of FieldsClauseTool.filter should be ' +
|
|
336
|
-
'a non-empty String, but %s given.',
|
|
336
|
+
'a non-empty String, but %s was given.',
|
|
337
337
|
v,
|
|
338
338
|
);
|
|
339
339
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -360,7 +360,7 @@ describe('FieldsClauseTool', function () {
|
|
|
360
360
|
const error = v =>
|
|
361
361
|
format(
|
|
362
362
|
'The provided option "fields" should be a non-empty String ' +
|
|
363
|
-
'or an Array of non-empty String, but %s given.',
|
|
363
|
+
'or an Array of non-empty String, but %s was given.',
|
|
364
364
|
v,
|
|
365
365
|
);
|
|
366
366
|
expect(throwable([''])).to.throw(error('""'));
|
|
@@ -414,7 +414,7 @@ describe('FieldsClauseTool', function () {
|
|
|
414
414
|
const error = v =>
|
|
415
415
|
format(
|
|
416
416
|
'The provided option "fields" should be a non-empty String ' +
|
|
417
|
-
'or an Array of non-empty String, but %s given.',
|
|
417
|
+
'or an Array of non-empty String, but %s was given.',
|
|
418
418
|
v,
|
|
419
419
|
);
|
|
420
420
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -435,7 +435,7 @@ describe('FieldsClauseTool', function () {
|
|
|
435
435
|
const error = v =>
|
|
436
436
|
format(
|
|
437
437
|
'The provided option "fields" should be a non-empty String ' +
|
|
438
|
-
'or an Array of non-empty String, but %s given.',
|
|
438
|
+
'or an Array of non-empty String, but %s was given.',
|
|
439
439
|
v,
|
|
440
440
|
);
|
|
441
441
|
expect(throwable([''])).to.throw(error('""'));
|
|
@@ -460,7 +460,7 @@ describe('FieldsClauseTool', function () {
|
|
|
460
460
|
const error = v =>
|
|
461
461
|
format(
|
|
462
462
|
'The provided option "fields" should be a non-empty String ' +
|
|
463
|
-
'or an Array of non-empty String, but %s given.',
|
|
463
|
+
'or an Array of non-empty String, but %s was given.',
|
|
464
464
|
v,
|
|
465
465
|
);
|
|
466
466
|
expect(throwable('')).to.throw(error('""'));
|
|
@@ -487,7 +487,7 @@ describe('FieldsClauseTool', function () {
|
|
|
487
487
|
const error = v =>
|
|
488
488
|
format(
|
|
489
489
|
'The provided option "fields" should be a non-empty String ' +
|
|
490
|
-
'or an Array of non-empty String, but %s given.',
|
|
490
|
+
'or an Array of non-empty String, but %s was given.',
|
|
491
491
|
v,
|
|
492
492
|
);
|
|
493
493
|
expect(throwable([''])).to.throw(error('""'));
|