Uploaded image for project: 'Compass '
  1. Compass
  2. COMPASS-4803

Pre-populate validation rule editor with an example

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Schema Validation, UI / UX
    • None

      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:

            Assignee:
            Unassigned Unassigned
            Reporter:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: