OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

I'm trying to create a validation rule for an existing collection but I'm getting an error

  • Thread starter Thread starter Richelle Asmah
  • Start date Start date
R

Richelle Asmah

Guest
I had the below error

BSON field 'collMod.validator' is the wrong type 'string', expected type 'object'

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" })

<p>I had the below error</p>
<p>BSON field 'collMod.validator' is the wrong type 'string', expected type 'object'</p>

<p>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"
})</p>
 
Top