@e22m4u/js-repository 0.8.7 → 0.8.8
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/cjs/index.cjs +359 -300
- package/package.json +3 -3
- package/src/adapter/adapter-loader.js +2 -5
- package/src/adapter/adapter-loader.spec.js +2 -2
- package/src/adapter/adapter-registry.spec.js +2 -2
- package/src/adapter/builtin/memory-adapter.js +5 -5
- package/src/adapter/builtin/memory-adapter.spec.js +12 -12
- package/src/adapter/decorator/data-sanitizing-decorator.js +1 -2
- package/src/adapter/decorator/default-values-decorator.js +1 -2
- package/src/adapter/decorator/fields-filtering-decorator.js +1 -2
- package/src/adapter/decorator/inclusion-decorator.js +1 -2
- package/src/adapter/decorator/property-uniqueness-decorator.js +1 -2
- package/src/adapter/decorator/required-property-decorator.js +1 -2
- package/src/database-schema.spec.js +3 -5
- package/src/definition/datasource/datasource-definition-validator.js +3 -3
- package/src/definition/datasource/datasource-definition-validator.spec.js +3 -6
- package/src/definition/definition-registry.js +4 -7
- package/src/definition/definition-registry.spec.js +4 -6
- package/src/definition/model/model-data-sanitizer.js +2 -4
- package/src/definition/model/model-definition-utils.js +12 -14
- package/src/definition/model/model-definition-utils.spec.js +12 -21
- package/src/definition/model/model-definition-validator.js +12 -12
- package/src/definition/model/model-definition-validator.spec.js +12 -15
- package/src/definition/model/properties/primary-keys-definition-validator.js +4 -4
- package/src/definition/model/properties/primary-keys-definition-validator.spec.js +8 -8
- package/src/definition/model/properties/properties-definition-validator.js +42 -43
- package/src/definition/model/properties/properties-definition-validator.spec.js +45 -45
- package/src/definition/model/properties/property-uniqueness-validator.js +7 -11
- package/src/definition/model/properties/property-uniqueness-validator.spec.js +57 -60
- package/src/definition/model/properties/required-property-validator.js +1 -1
- package/src/definition/model/properties/required-property-validator.spec.js +1 -1
- package/src/definition/model/relations/relations-definition-validator.js +40 -42
- package/src/definition/model/relations/relations-definition-validator.spec.js +44 -45
- 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 +95 -53
- package/src/filter/fields-clause-tool.spec.js +210 -387
- package/src/filter/include-clause-tool.js +9 -9
- package/src/filter/include-clause-tool.spec.js +4 -4
- package/src/filter/operator-clause-tool.js +20 -32
- package/src/filter/operator-clause-tool.spec.js +25 -49
- package/src/filter/order-clause-tool.js +55 -27
- package/src/filter/order-clause-tool.spec.js +151 -90
- package/src/filter/slice-clause-tool.js +5 -6
- package/src/filter/slice-clause-tool.spec.js +8 -24
- package/src/filter/where-clause-tool.js +18 -11
- package/src/filter/where-clause-tool.spec.js +27 -17
- package/src/relations/belongs-to-resolver.js +18 -30
- package/src/relations/belongs-to-resolver.spec.js +21 -44
- package/src/relations/has-many-resolver.js +28 -44
- package/src/relations/has-many-resolver.spec.js +44 -68
- package/src/relations/has-one-resolver.js +28 -44
- package/src/relations/has-one-resolver.spec.js +44 -68
- package/src/relations/references-many-resolver.js +8 -14
- package/src/relations/references-many-resolver.spec.js +12 -24
- package/src/repository/repository-registry.js +2 -2
- package/src/repository/repository.js +1 -1
- package/src/utils/exclude-object-keys.js +2 -2
- package/src/utils/exclude-object-keys.spec.js +2 -2
- package/src/utils/like-to-regexp.js +1 -2
- package/src/utils/like-to-regexp.spec.js +5 -5
- 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 +6 -7
- package/src/utils/select-object-keys.spec.js +3 -6
|
@@ -23,8 +23,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
23
23
|
const throwable = v => puv.validate(v, 'create', 'model', {});
|
|
24
24
|
const error = v =>
|
|
25
25
|
format(
|
|
26
|
-
'
|
|
27
|
-
'must be a Function, but %s was given.',
|
|
26
|
+
'Parameter "countMethod" must be a Function, but %s was given.',
|
|
28
27
|
v,
|
|
29
28
|
);
|
|
30
29
|
await expect(throwable('str')).to.be.rejectedWith(error('"str"'));
|
|
@@ -58,8 +57,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
58
57
|
const throwable = v => puv.validate(() => 0, v, 'model', {});
|
|
59
58
|
const error = v =>
|
|
60
59
|
format(
|
|
61
|
-
'
|
|
62
|
-
'
|
|
60
|
+
'Parameter "methodName" must be a non-empty String, ' +
|
|
61
|
+
'but %s was given.',
|
|
63
62
|
v,
|
|
64
63
|
);
|
|
65
64
|
await expect(throwable('')).to.be.rejectedWith(error('""'));
|
|
@@ -93,8 +92,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
93
92
|
const throwable = v => puv.validate(() => 0, 'create', v, {});
|
|
94
93
|
const error = v =>
|
|
95
94
|
format(
|
|
96
|
-
'
|
|
97
|
-
'must be a non-empty String, but %s was given.',
|
|
95
|
+
'Parameter "modelName" must be a non-empty String, but %s was given.',
|
|
98
96
|
v,
|
|
99
97
|
);
|
|
100
98
|
await expect(throwable('')).to.be.rejectedWith(error('""'));
|
|
@@ -128,7 +126,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
128
126
|
const throwable = v => puv.validate(() => 0, 'create', 'model', v);
|
|
129
127
|
const error = v =>
|
|
130
128
|
format(
|
|
131
|
-
'
|
|
129
|
+
'Data of the model "model" must be an Object, but %s was given.',
|
|
132
130
|
v,
|
|
133
131
|
);
|
|
134
132
|
await expect(throwable('str')).to.be.rejectedWith(error('"str"'));
|
|
@@ -241,8 +239,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
241
239
|
const puv = dbs.getService(PropertyUniquenessValidator);
|
|
242
240
|
const promise = puv.validate(() => 1, 'unsupported', 'model', {});
|
|
243
241
|
await expect(promise).to.be.rejectedWith(
|
|
244
|
-
'
|
|
245
|
-
'support the adapter method "unsupported".',
|
|
242
|
+
'Adapter method "unsupported" is not supported.',
|
|
246
243
|
);
|
|
247
244
|
});
|
|
248
245
|
|
|
@@ -264,8 +261,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
264
261
|
foo: 'bar',
|
|
265
262
|
});
|
|
266
263
|
await expect(promise).to.be.rejectedWith(
|
|
267
|
-
'
|
|
268
|
-
'the property "foo" with the value "bar" and
|
|
264
|
+
'Existing document of the model "model" already has ' +
|
|
265
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
269
266
|
);
|
|
270
267
|
});
|
|
271
268
|
|
|
@@ -341,8 +338,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
341
338
|
1,
|
|
342
339
|
);
|
|
343
340
|
await expect(promise).to.be.rejectedWith(
|
|
344
|
-
'
|
|
345
|
-
'the property "foo" with the value "bar" and
|
|
341
|
+
'Existing document of the model "model" already has ' +
|
|
342
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
346
343
|
);
|
|
347
344
|
});
|
|
348
345
|
|
|
@@ -466,8 +463,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
466
463
|
foo: 'bar',
|
|
467
464
|
});
|
|
468
465
|
await expect(promise).to.be.rejectedWith(
|
|
469
|
-
'
|
|
470
|
-
'the property "foo" with the value "bar" and
|
|
466
|
+
'Existing document of the model "model" already has ' +
|
|
467
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
471
468
|
);
|
|
472
469
|
});
|
|
473
470
|
|
|
@@ -795,8 +792,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
795
792
|
const puv = dbs.getService(PropertyUniquenessValidator);
|
|
796
793
|
const promise = puv.validate(() => 1, 'patch', 'model', {foo: 'bar'});
|
|
797
794
|
await expect(promise).to.be.rejectedWith(
|
|
798
|
-
'
|
|
799
|
-
'the property "foo" with the value "bar" and
|
|
795
|
+
'Existing document of the model "model" already has ' +
|
|
796
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
800
797
|
);
|
|
801
798
|
});
|
|
802
799
|
|
|
@@ -815,7 +812,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
815
812
|
await puv.validate(() => 0, 'patch', 'model', {foo: 'bar'});
|
|
816
813
|
});
|
|
817
814
|
|
|
818
|
-
it('invokes the "countMethod" for given properties which
|
|
815
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
819
816
|
const dbs = new DatabaseSchema();
|
|
820
817
|
dbs.defineModel({
|
|
821
818
|
name: 'model',
|
|
@@ -867,8 +864,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
867
864
|
baz: 'qux',
|
|
868
865
|
});
|
|
869
866
|
await expect(promise1).to.be.rejectedWith(
|
|
870
|
-
'
|
|
871
|
-
'the property "foo" with the value "bar" and
|
|
867
|
+
'Existing document of the model "model" already has ' +
|
|
868
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
872
869
|
);
|
|
873
870
|
await expect(promise2).not.to.be.rejected;
|
|
874
871
|
});
|
|
@@ -895,8 +892,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
895
892
|
1,
|
|
896
893
|
);
|
|
897
894
|
await expect(promise).to.be.rejectedWith(
|
|
898
|
-
'
|
|
899
|
-
'the property "foo" with the value "bar" and
|
|
895
|
+
'Existing document of the model "model" already has ' +
|
|
896
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
900
897
|
);
|
|
901
898
|
});
|
|
902
899
|
|
|
@@ -915,7 +912,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
915
912
|
await puv.validate(() => 0, 'patchById', 'model', {foo: 'bar'}, 1);
|
|
916
913
|
});
|
|
917
914
|
|
|
918
|
-
it('invokes the "countMethod" for given properties which
|
|
915
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
919
916
|
const dbs = new DatabaseSchema();
|
|
920
917
|
dbs.defineModel({
|
|
921
918
|
name: 'model',
|
|
@@ -977,8 +974,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
977
974
|
baz: 'qux',
|
|
978
975
|
});
|
|
979
976
|
await expect(promise1).to.be.rejectedWith(
|
|
980
|
-
'
|
|
981
|
-
'the property "foo" with the value "bar" and
|
|
977
|
+
'Existing document of the model "model" already has ' +
|
|
978
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
982
979
|
);
|
|
983
980
|
await expect(promise2).not.to.be.rejected;
|
|
984
981
|
});
|
|
@@ -1042,8 +1039,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1042
1039
|
foo: 'bar',
|
|
1043
1040
|
});
|
|
1044
1041
|
await expect(promise).to.be.rejectedWith(
|
|
1045
|
-
'
|
|
1046
|
-
'the property "foo" with the value "bar" and
|
|
1042
|
+
'Existing document of the model "model" already has ' +
|
|
1043
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1047
1044
|
);
|
|
1048
1045
|
});
|
|
1049
1046
|
|
|
@@ -1119,8 +1116,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1119
1116
|
1,
|
|
1120
1117
|
);
|
|
1121
1118
|
await expect(promise).to.be.rejectedWith(
|
|
1122
|
-
'
|
|
1123
|
-
'the property "foo" with the value "bar" and
|
|
1119
|
+
'Existing document of the model "model" already has ' +
|
|
1120
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1124
1121
|
);
|
|
1125
1122
|
});
|
|
1126
1123
|
|
|
@@ -1244,8 +1241,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1244
1241
|
foo: 'bar',
|
|
1245
1242
|
});
|
|
1246
1243
|
await expect(promise).to.be.rejectedWith(
|
|
1247
|
-
'
|
|
1248
|
-
'the property "foo" with the value "bar" and
|
|
1244
|
+
'Existing document of the model "model" already has ' +
|
|
1245
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1249
1246
|
);
|
|
1250
1247
|
});
|
|
1251
1248
|
|
|
@@ -1573,8 +1570,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1573
1570
|
const puv = dbs.getService(PropertyUniquenessValidator);
|
|
1574
1571
|
const promise = puv.validate(() => 1, 'patch', 'model', {foo: 'bar'});
|
|
1575
1572
|
await expect(promise).to.be.rejectedWith(
|
|
1576
|
-
'
|
|
1577
|
-
'the property "foo" with the value "bar" and
|
|
1573
|
+
'Existing document of the model "model" already has ' +
|
|
1574
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1578
1575
|
);
|
|
1579
1576
|
});
|
|
1580
1577
|
|
|
@@ -1593,7 +1590,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1593
1590
|
await puv.validate(() => 0, 'patch', 'model', {foo: 'bar'});
|
|
1594
1591
|
});
|
|
1595
1592
|
|
|
1596
|
-
it('invokes the "countMethod" for given properties which
|
|
1593
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
1597
1594
|
const dbs = new DatabaseSchema();
|
|
1598
1595
|
dbs.defineModel({
|
|
1599
1596
|
name: 'model',
|
|
@@ -1645,8 +1642,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1645
1642
|
baz: 'qux',
|
|
1646
1643
|
});
|
|
1647
1644
|
await expect(promise1).to.be.rejectedWith(
|
|
1648
|
-
'
|
|
1649
|
-
'the property "foo" with the value "bar" and
|
|
1645
|
+
'Existing document of the model "model" already has ' +
|
|
1646
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1650
1647
|
);
|
|
1651
1648
|
await expect(promise2).not.to.be.rejected;
|
|
1652
1649
|
});
|
|
@@ -1673,8 +1670,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1673
1670
|
1,
|
|
1674
1671
|
);
|
|
1675
1672
|
await expect(promise).to.be.rejectedWith(
|
|
1676
|
-
'
|
|
1677
|
-
'the property "foo" with the value "bar" and
|
|
1673
|
+
'Existing document of the model "model" already has ' +
|
|
1674
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1678
1675
|
);
|
|
1679
1676
|
});
|
|
1680
1677
|
|
|
@@ -1693,7 +1690,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1693
1690
|
await puv.validate(() => 0, 'patchById', 'model', {foo: 'bar'}, 1);
|
|
1694
1691
|
});
|
|
1695
1692
|
|
|
1696
|
-
it('invokes the "countMethod" for given properties which
|
|
1693
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
1697
1694
|
const dbs = new DatabaseSchema();
|
|
1698
1695
|
dbs.defineModel({
|
|
1699
1696
|
name: 'model',
|
|
@@ -1755,8 +1752,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1755
1752
|
baz: 'qux',
|
|
1756
1753
|
});
|
|
1757
1754
|
await expect(promise1).to.be.rejectedWith(
|
|
1758
|
-
'
|
|
1759
|
-
'the property "foo" with the value "bar" and
|
|
1755
|
+
'Existing document of the model "model" already has ' +
|
|
1756
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1760
1757
|
);
|
|
1761
1758
|
await expect(promise2).not.to.be.rejected;
|
|
1762
1759
|
});
|
|
@@ -1820,8 +1817,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1820
1817
|
foo: 'bar',
|
|
1821
1818
|
});
|
|
1822
1819
|
await expect(promise).to.be.rejectedWith(
|
|
1823
|
-
'
|
|
1824
|
-
'the property "foo" with the value "bar" and
|
|
1820
|
+
'Existing document of the model "model" already has ' +
|
|
1821
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
1825
1822
|
);
|
|
1826
1823
|
});
|
|
1827
1824
|
|
|
@@ -1840,7 +1837,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
1840
1837
|
await puv.validate(() => 0, 'create', 'model', {foo: 'bar'});
|
|
1841
1838
|
});
|
|
1842
1839
|
|
|
1843
|
-
it('invokes the "countMethod" for given properties which
|
|
1840
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
1844
1841
|
const dbs = new DatabaseSchema();
|
|
1845
1842
|
dbs.defineModel({
|
|
1846
1843
|
name: 'model',
|
|
@@ -2011,8 +2008,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2011
2008
|
1,
|
|
2012
2009
|
);
|
|
2013
2010
|
await expect(promise).to.be.rejectedWith(
|
|
2014
|
-
'
|
|
2015
|
-
'the property "foo" with the value "bar" and
|
|
2011
|
+
'Existing document of the model "model" already has ' +
|
|
2012
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
2016
2013
|
);
|
|
2017
2014
|
});
|
|
2018
2015
|
|
|
@@ -2031,7 +2028,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2031
2028
|
await puv.validate(() => 0, 'replaceById', 'model', {foo: 'bar'}, 1);
|
|
2032
2029
|
});
|
|
2033
2030
|
|
|
2034
|
-
it('invokes the "countMethod" for given properties which
|
|
2031
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
2035
2032
|
const dbs = new DatabaseSchema();
|
|
2036
2033
|
dbs.defineModel({
|
|
2037
2034
|
name: 'model',
|
|
@@ -2287,8 +2284,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2287
2284
|
foo: 'bar',
|
|
2288
2285
|
});
|
|
2289
2286
|
await expect(promise).to.be.rejectedWith(
|
|
2290
|
-
'
|
|
2291
|
-
'the property "foo" with the value "bar" and
|
|
2287
|
+
'Existing document of the model "model" already has ' +
|
|
2288
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
2292
2289
|
);
|
|
2293
2290
|
});
|
|
2294
2291
|
|
|
@@ -2307,7 +2304,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2307
2304
|
await puv.validate(() => 0, 'replaceOrCreate', 'model', {foo: 'bar'});
|
|
2308
2305
|
});
|
|
2309
2306
|
|
|
2310
|
-
it('invokes the "countMethod" for given properties which
|
|
2307
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
2311
2308
|
const dbs = new DatabaseSchema();
|
|
2312
2309
|
dbs.defineModel({
|
|
2313
2310
|
name: 'model',
|
|
@@ -2958,8 +2955,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2958
2955
|
const puv = dbs.getService(PropertyUniquenessValidator);
|
|
2959
2956
|
const promise = puv.validate(() => 1, 'patch', 'model', {foo: 'bar'});
|
|
2960
2957
|
await expect(promise).to.be.rejectedWith(
|
|
2961
|
-
'
|
|
2962
|
-
'the property "foo" with the value "bar" and
|
|
2958
|
+
'Existing document of the model "model" already has ' +
|
|
2959
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
2963
2960
|
);
|
|
2964
2961
|
});
|
|
2965
2962
|
|
|
@@ -2978,7 +2975,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
2978
2975
|
await puv.validate(() => 0, 'patch', 'model', {foo: 'bar'});
|
|
2979
2976
|
});
|
|
2980
2977
|
|
|
2981
|
-
it('invokes the "countMethod" for given properties which
|
|
2978
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
2982
2979
|
const dbs = new DatabaseSchema();
|
|
2983
2980
|
dbs.defineModel({
|
|
2984
2981
|
name: 'model',
|
|
@@ -3030,8 +3027,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
3030
3027
|
baz: 'qux',
|
|
3031
3028
|
});
|
|
3032
3029
|
await expect(promise1).to.be.rejectedWith(
|
|
3033
|
-
'
|
|
3034
|
-
'the property "foo" with the value "bar" and
|
|
3030
|
+
'Existing document of the model "model" already has ' +
|
|
3031
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
3035
3032
|
);
|
|
3036
3033
|
await expect(promise2).not.to.be.rejected;
|
|
3037
3034
|
});
|
|
@@ -3174,8 +3171,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
3174
3171
|
1,
|
|
3175
3172
|
);
|
|
3176
3173
|
await expect(promise).to.be.rejectedWith(
|
|
3177
|
-
'
|
|
3178
|
-
'the property "foo" with the value "bar" and
|
|
3174
|
+
'Existing document of the model "model" already has ' +
|
|
3175
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
3179
3176
|
);
|
|
3180
3177
|
});
|
|
3181
3178
|
|
|
@@ -3194,7 +3191,7 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
3194
3191
|
await puv.validate(() => 0, 'patchById', 'model', {foo: 'bar'}, 1);
|
|
3195
3192
|
});
|
|
3196
3193
|
|
|
3197
|
-
it('invokes the "countMethod" for given properties which
|
|
3194
|
+
it('invokes the "countMethod" for given properties which must be unique', async function () {
|
|
3198
3195
|
const dbs = new DatabaseSchema();
|
|
3199
3196
|
dbs.defineModel({
|
|
3200
3197
|
name: 'model',
|
|
@@ -3256,8 +3253,8 @@ describe('PropertyUniquenessValidator', function () {
|
|
|
3256
3253
|
baz: 'qux',
|
|
3257
3254
|
});
|
|
3258
3255
|
await expect(promise1).to.be.rejectedWith(
|
|
3259
|
-
'
|
|
3260
|
-
'the property "foo" with the value "bar" and
|
|
3256
|
+
'Existing document of the model "model" already has ' +
|
|
3257
|
+
'the property "foo" with the value "bar" and must be unique.',
|
|
3261
3258
|
);
|
|
3262
3259
|
await expect(promise2).not.to.be.rejected;
|
|
3263
3260
|
});
|
|
@@ -27,7 +27,7 @@ export class RequiredPropertyValidator extends Service {
|
|
|
27
27
|
Array.isArray(modelData)
|
|
28
28
|
) {
|
|
29
29
|
throw new InvalidArgumentError(
|
|
30
|
-
'Data of the model %v
|
|
30
|
+
'Data of the model %v must be an Object, but %v was given.',
|
|
31
31
|
modelName,
|
|
32
32
|
modelData,
|
|
33
33
|
);
|
|
@@ -35,7 +35,7 @@ describe('RequiredPropertyValidator', function () {
|
|
|
35
35
|
const throwable = v => () => S.validate('model', v);
|
|
36
36
|
const error = s =>
|
|
37
37
|
format(
|
|
38
|
-
'Data of the model "model"
|
|
38
|
+
'Data of the model "model" must be an Object, but %s was given.',
|
|
39
39
|
s,
|
|
40
40
|
);
|
|
41
41
|
expect(throwable('str')).to.throw(error('"str"'));
|