I found a way to do it:
const getPathInObject = (object, path, defaultValue) => path
.split(".")
.reduce((o, p) => (o ? o[p] : defaultValue), object)
const areAllFieldsSet = (document: any) => {
const notFilledFields = Object
.keys(MySchema.schema.paths)
.filter((path) => getPathInObject(document, path, undefined) === undefined)
return notFilledFields.length === 0
}
If anybody knows a better way, please let me know!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…