I had the below error
BSON field ‘collMod.validator’ is the wrong type ‘string’, expected type ‘object’
this is my code
db.runCommand({
collMod: “SignUp”,
validator: {
$jsonSchema: {
bsonType: “object”,
required: [“FirstName”, “LastName”, “Email”, “Password”, “Confirm_Password”],
properties: {
FirstName: { bsonType: “string” },
LastName: { bsonType: “string” },
Email: {
bsonType: “string”,
pattern: “^[^@s]+@[^@s]+.[^@s]+$”,
},
Password: {
bsonType: “string”,
minLength: 8,
maxLength: 20,
},
Confirm_Password: {
bsonType: “string”,
minLength: 8,
maxLength: 20,
}
}
}
},
validationLevel: “strict”,
validationAction: “error”
})
I wanted to create a validation for my SignUp collection
Richelle Asmah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.