I am using pymongo and creating a collection but it throw some issue when I am using
"minimun": 2017,
"maximum": 3017,
full code is
student_validator = {
"$jsonSchema": {
"bsonType": "object",
"title": "Student Object Validaton",
"required": ["address", "major", "name", "year"],
"properties": {
"name": {
"bsonType": "string",
"description": "'name' must be a string and is required"
},
"year": {
"bsonType": "int",
"minimun": 2017,
"maximum": 3017,
"description": "'year' must be an integer in [ 2017, 3017 ] and is required"
},
"gpa": {
"bsonType": "boudle",
"description": "'gpa' must be a double if the field exists"
},
}
}
}
try:
db.create_collection("student", validator=student_validator)
except Exception as e:
print(e)
and error is
Unknown $jsonSchema keyword: minimun, full error: {'ok': 0.0, 'errmsg': 'Unknown $jsonSchema keyword: minimun', 'code': 9, 'codeName': 'FailedToParse'}
and code reference from mongodb docs
https://www.mongodb.com/docs/manual/core/schema-validation/specify-json-schema/#create-a-collection-with-validation.