Skip to content

Commit 2428fd0

Browse files
authored
feat(mongodb-constants): add validation template COMPASS-8660 (#519)
1 parent 5578940 commit 2428fd0

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

packages/mongodb-constants/src/index.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ describe('constants', function () {
2929
'FULL_SCAN_STAGES',
3030
'REQUIRED_AS_FIRST_STAGE',
3131
'SYSTEM_VARIABLES',
32+
'VALIDATION_TEMPLATE',
3233
'ATLAS_SEARCH_TEMPLATES',
3334
'ATLAS_VECTOR_SEARCH_TEMPLATE',
3435
]);

packages/mongodb-constants/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from './ns';
99
export * from './query-operators';
1010
export * from './stage-operators';
1111
export * from './system-variables';
12+
export * from './validation-template';
1213
export { getFilteredCompletions, wrapField } from './filter';
1314
export type {
1415
Completion,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const VALIDATION_TEMPLATE = `/**
2+
* This is a starter template for a schema validation rule for a collection.
3+
* More information on schema validation rules can be found at:
4+
* https://www.mongodb.com/docs/manual/core/schema-validation/
5+
*/
6+
{
7+
$jsonSchema: {
8+
title: "Library.books",
9+
bsonType: "object",
10+
required: ["fieldname1", "fieldname2"],
11+
properties: {
12+
fieldname1: {
13+
bsonType: "string",
14+
description: "Fieldname1 must be a string",
15+
},
16+
fieldname2: {
17+
bsonType: "int",
18+
description: "Fieldname2 must be an integer",
19+
},
20+
arrayFieldName: {
21+
bsonType: "array",
22+
items: {
23+
bsonType: "string"
24+
},
25+
description: "arrayFieldName must be an array of strings"
26+
},
27+
}
28+
}
29+
}`;

0 commit comments

Comments
 (0)