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

validator can not validate array.

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Minor - P4 Minor - P4
    • None
    • 3.2.5
    • Storage
    • None
    • ALL

    Description

      Hi.

      I try to validate arry. But it does not work.

      First I make collection with validator.

      > db.createCollection("user" , {
      ...     validator : {
      ...          hoge : { $type : "array" }}})
      { "ok" : 1 }
       
      > db.user.insert({"hoge":1})
      WriteResult({
              "nInserted" : 0,
              "writeError" : {
                      "code" : 121,
                      "errmsg" : "Document failed validation"
              }
      })
       
      # => This is correct
       
      > db.user.insert({"hoge":[1,2,3]})
      WriteResult({
              "nInserted" : 0,
              "writeError" : {
                      "code" : 121,
                      "errmsg" : "Document failed validation"
              }
      })
       
      # => This is wrong!
      

      Attachments

        Activity

          People

            kelsey.schubert@mongodb.com Kelsey Schubert
            fetaro@gmail.com tetsutaro watanabe
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: