@bedrockio/model 0.1.27 → 0.1.28
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/validation.js +8 -1
- package/package.json +3 -3
- package/src/validation.js +8 -1
- package/types/include.d.ts +1 -1
- package/types/search.d.ts +1 -1
- package/types/validation.d.ts +2 -2
- package/types/validation.d.ts.map +1 -1
package/dist/cjs/validation.js
CHANGED
|
@@ -268,7 +268,14 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
268
268
|
schema = schema.required();
|
|
269
269
|
}
|
|
270
270
|
if (typedef.default) {
|
|
271
|
-
|
|
271
|
+
// Note that adding a default in the validation is
|
|
272
|
+
// technically unnecessary as this will be handled
|
|
273
|
+
// at the model level, however fixed values can be
|
|
274
|
+
// reported to the OpenAPI definition to enrich
|
|
275
|
+
// documentation.
|
|
276
|
+
if (typeof typedef.default !== 'function') {
|
|
277
|
+
schema = schema.default(typedef.default);
|
|
278
|
+
}
|
|
272
279
|
}
|
|
273
280
|
if (typedef.validate?.schema) {
|
|
274
281
|
schema = schema.append(typedef.validate.schema);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bedrockio/model",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"description": "Bedrock utilities for model creation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"lodash": "^4.17.21"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@bedrockio/yada": "^1.0.
|
|
32
|
+
"@bedrockio/yada": "^1.0.30",
|
|
33
33
|
"mongoose": ">=6.9.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@babel/core": "^7.20.12",
|
|
38
38
|
"@babel/preset-env": "^7.20.2",
|
|
39
39
|
"@bedrockio/prettier-config": "^1.0.2",
|
|
40
|
-
"@bedrockio/yada": "^1.0.
|
|
40
|
+
"@bedrockio/yada": "^1.0.30",
|
|
41
41
|
"@shelf/jest-mongodb": "^4.1.6",
|
|
42
42
|
"babel-plugin-import-replacement": "^1.0.1",
|
|
43
43
|
"eslint": "^8.33.0",
|
package/src/validation.js
CHANGED
|
@@ -280,7 +280,14 @@ function getSchemaForTypedef(typedef, options = {}) {
|
|
|
280
280
|
schema = schema.required();
|
|
281
281
|
}
|
|
282
282
|
if (typedef.default) {
|
|
283
|
-
|
|
283
|
+
// Note that adding a default in the validation is
|
|
284
|
+
// technically unnecessary as this will be handled
|
|
285
|
+
// at the model level, however fixed values can be
|
|
286
|
+
// reported to the OpenAPI definition to enrich
|
|
287
|
+
// documentation.
|
|
288
|
+
if (typeof typedef.default !== 'function') {
|
|
289
|
+
schema = schema.default(typedef.default);
|
|
290
|
+
}
|
|
284
291
|
}
|
|
285
292
|
if (typedef.validate?.schema) {
|
|
286
293
|
schema = schema.append(typedef.validate.schema);
|
package/types/include.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const INCLUDE_FIELD_SCHEMA: {
|
|
|
12
12
|
assertions: any[];
|
|
13
13
|
meta: {};
|
|
14
14
|
required(): any;
|
|
15
|
-
default(
|
|
15
|
+
default(arg: any): any;
|
|
16
16
|
custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
|
|
17
17
|
strip(strip: any): any;
|
|
18
18
|
allow(...set: any[]): any;
|
package/types/search.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function searchValidation(options?: {}): {
|
|
|
10
10
|
assertions: any[];
|
|
11
11
|
meta: {};
|
|
12
12
|
required(): any;
|
|
13
|
-
default(
|
|
13
|
+
default(arg: any): any;
|
|
14
14
|
custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
|
|
15
15
|
strip(strip: any): any;
|
|
16
16
|
allow(...set: any[]): any;
|
package/types/validation.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export function getTupleValidator(types: any): {
|
|
|
10
10
|
schema: any;
|
|
11
11
|
};
|
|
12
12
|
export const OBJECT_ID_SCHEMA: {
|
|
13
|
+
required(): any;
|
|
13
14
|
length(length: number): any;
|
|
14
15
|
min(length: number): any;
|
|
15
16
|
max(length: number): any;
|
|
@@ -69,8 +70,7 @@ export const OBJECT_ID_SCHEMA: {
|
|
|
69
70
|
toString(): any;
|
|
70
71
|
assertions: any[];
|
|
71
72
|
meta: {};
|
|
72
|
-
|
|
73
|
-
default(value: any): any;
|
|
73
|
+
default(arg: any): any;
|
|
74
74
|
custom(...args: import("@bedrockio/yada/types/Schema").CustomSignature): any;
|
|
75
75
|
strip(strip: any): any;
|
|
76
76
|
allow(...set: any[]): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAiFC;AAsBD,wEAkBC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../src/validation.js"],"names":[],"mappings":"AAiFA,kDAEC;AAED,oEAiFC;AAsBD,wEAkBC;AAoRD;;;EAEC;AAED;;;EAOC;AA3dD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQK"}
|