I'm creating Collection USER where he is asked to add an email field.
This is what I have in the validation collection.
db.createCollection("user", {
validator: {
$jsonSchema : {
bsonType: "object",
required: ["email"],
properties: {
"email": {type: "string", pattern: "^(\\([a-z] {30}\\))?[a-z]{30}@[.]$"}
}}}})
I expect MongoDB to accept email in "email@email.com" format. The validation does not allow such a pattern.
WriteResult({
"nInserted" : 0,
"writeError" : {
"code" : 121,
"errmsg" : "Document failed validation"
}})
Aucun commentaire:
Enregistrer un commentaire