@bedrockio/model 0.13.0 → 0.13.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.
- package/CHANGELOG.md +4 -0
- package/dist/cjs/validation.js +3 -1
- package/package.json +1 -1
- package/src/validation.js +3 -1
- package/types/validation.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/validation.js
CHANGED
|
@@ -58,6 +58,7 @@ function applyValidation(schema, definition) {
|
|
|
58
58
|
return getSchemaFromMongoose(schema, {
|
|
59
59
|
model: this,
|
|
60
60
|
stripEmpty: true,
|
|
61
|
+
applyUnique: true,
|
|
61
62
|
stripDeleted: true,
|
|
62
63
|
allowInclude: false,
|
|
63
64
|
stripTimestamps: true,
|
|
@@ -71,6 +72,7 @@ function applyValidation(schema, definition) {
|
|
|
71
72
|
return getSchemaFromMongoose(schema, {
|
|
72
73
|
model: this,
|
|
73
74
|
allowNull: true,
|
|
75
|
+
applyUnique: true,
|
|
74
76
|
skipRequired: true,
|
|
75
77
|
stripUnknown: true,
|
|
76
78
|
stripDeleted: true,
|
|
@@ -304,7 +306,7 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
304
306
|
if (typedef.writeAccess && options.requireWriteAccess) {
|
|
305
307
|
schema = validateAccess('write', schema, typedef.writeAccess, options);
|
|
306
308
|
}
|
|
307
|
-
if (typedef.softUnique) {
|
|
309
|
+
if (typedef.softUnique && options.applyUnique) {
|
|
308
310
|
schema = schema.custom(async (value, {
|
|
309
311
|
path,
|
|
310
312
|
originalRoot
|
package/package.json
CHANGED
package/src/validation.js
CHANGED
|
@@ -60,6 +60,7 @@ export function applyValidation(schema, definition) {
|
|
|
60
60
|
return getSchemaFromMongoose(schema, {
|
|
61
61
|
model: this,
|
|
62
62
|
stripEmpty: true,
|
|
63
|
+
applyUnique: true,
|
|
63
64
|
stripDeleted: true,
|
|
64
65
|
allowInclude: false,
|
|
65
66
|
stripTimestamps: true,
|
|
@@ -74,6 +75,7 @@ export function applyValidation(schema, definition) {
|
|
|
74
75
|
return getSchemaFromMongoose(schema, {
|
|
75
76
|
model: this,
|
|
76
77
|
allowNull: true,
|
|
78
|
+
applyUnique: true,
|
|
77
79
|
skipRequired: true,
|
|
78
80
|
stripUnknown: true,
|
|
79
81
|
stripDeleted: true,
|
|
@@ -326,7 +328,7 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
326
328
|
schema = validateAccess('write', schema, typedef.writeAccess, options);
|
|
327
329
|
}
|
|
328
330
|
|
|
329
|
-
if (typedef.softUnique) {
|
|
331
|
+
if (typedef.softUnique && options.applyUnique) {
|
|
330
332
|
schema = schema.custom(async (value, { path, originalRoot }) => {
|
|
331
333
|
const { id } = originalRoot;
|
|
332
334
|
await assertUnique({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAqDA,kDAEC;AAED,oEA2FC;AAsBD,wEAiBC;AA8SD;;;EAEC;AAED;;;EAOC"}
|