[COMPASS-4388] problem inserting document having validation of bsontype int and bsontype array Created: 12/Aug/20  Updated: 16/Sep/20  Resolved: 16/Sep/20

Status: Closed
Project: Compass
Component/s: Schema Validation
Affects Version/s: None
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: marco ruseo Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed

 Description   

Hello, 

im trying to insert a document containing some int, string and an array.

I have a validation schema :like this

numbers:

{ bsonType: [ 'int' ], description: '' }

,

data: {
bsonType: [
'array'
],
minItems: 1,
uniqueItems: true,
additionalProperties: false,
items: {
bsonType: [
'object'
],
required: [
'idData',
'dataName'
],
additionalProperties: false,
properties: {
idData:

{ bsonType: [ 'objectId' ], description: '' }

,
dataName:

{ bsonType: 'string', description: '' }

}
}
}

 

 

If i try to insert a document containing int and array it fails validation, 

if i insert the same document , but  change the bsontype of numbers from 'int' to 'double'

the validation goes ok and the document is inserted.

Can u help pls?

 

this is the document i try to insert :

 

{    {        "numbers": 2,     "data": [

{         "idData":new ObjectId(), "dataName": "name"        }

    ]
}

 



 Comments   
Comment by Massimiliano Marcon [ 16/Sep/20 ]

Not enough information to reproduce the problem.

Comment by Massimiliano Marcon [ 26/Aug/20 ]

rauseom@libero.it I am having a hard time reproducing the problem.

That looks like JSON Schema, but there is stuff missing. Can you post the entire validator (posting it as a code block, please )?

It should look something like this:

{
  $jsonSchema: {
    //...
  }
}

See an example here: https://docs.mongodb.com/manual/reference/operator/query/jsonSchema/#schema-validation

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