Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-40251

Better validation error on insert and update

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Logging
    • Labels:
      None

      When creating or updating an invalid document on a collection that has validation the error message that comes up is far too generic 

       

      WriteResult({ 
          "nInserted" : 0, "writeError" : { 
              "code" : 121, "errmsg" : "Document failed validation" 
          } 
      })
      

       

      Could the team please implement something nicer that i possibly includes the description and or the key name 

      like if the validation looked like

      gpa: {
          bsonType: [ "double" ], description: "must be a double and is required" }
      

      And somebody entered an incorrect validation the error message back could include 

      validationErrors: [ Gpa must be a double and is required]

      With the validation at its current state its pretty useless for an application level and the validation would need to be duplicated on the application level as well as the db level.

       

      Thanks

            Assignee:
            eric.sedor@mongodb.com Eric Sedor
            Reporter:
            ihsanm Ihsan Mujdeci
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: