Update operation of mongoose

  mongodb, question

When modifying the data in the table, when the field type in the table is Boolean, both strings and numbers will be directly converted to true.
While fields of string format type receive any incoming modified data types. How can complete and strict data verification be achieved

The main question should be a question such as document validation.
Direct viewing of official documents:https://docs.mongodb.com/manual/core/document-validation/

db.createCollection( "contacts",
 { validator: { $or:
 [
 { phone: { $type: "string" } },
 { email: { $regex: /@mongodb\.com$/ } },
 { status: { $in: [ "Unknown", "Incomplete" ] } }
 ]
 }
 } )
 
 How to use it in combination with your needs and mongo documents?