[COMPASS-4803] Pre-populate validation rule editor with an example Created: 06/May/21  Updated: 23/Jan/23

Status: Open
Project: Compass
Component/s: Schema Validation, UI / UX
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Katya Kamenieva Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2021-05-30 at 14.40.56.png    
Epic Link: COMPASS-6115

 Description   

Given $jsonSchema in MongoDB is slightly different from the standard, we could help users to start by generating some basic schema for their collection when they click 'Add Rule'. For example, suggest type checks.

If you use some of the online tools to generate JSON Schema you'll get something like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
     "student_name": {
      "type": "string"
    },
  ...
  },
  "required": [
    ...
  ]
} 

This is not easily copy-pasteable into the editor. If the editor contained some valid default value, it would make it easier for users to understand how to compose the rule.

{$jsonSchema: {
  "properties": {
    "student_name": {
      "bsonType": "string"
    },
    "class_id": {
      "bsonType": "int"
    }
  }
}} 

This is available in Realm during configuration of the collection:


Generated at Wed Feb 07 22:37:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.