Skip to content

Commit

Permalink
Fixing Model.update required attribute prefix same matching
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcharlie committed Aug 19, 2021
1 parent 1e9667b commit 1328a51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Document.ts
Expand Up @@ -468,7 +468,7 @@ Document.objectFromSchema = async function (object: any, model: Model<Document>,
if (settings.required) {
let attributesToCheck = await Document.attributesWithSchema(returnObject, model);
if (settings.required === "nested") {
attributesToCheck = attributesToCheck.filter((attribute) => utils.object.keys(returnObject).find((key) => attribute.startsWith(key)));
attributesToCheck = attributesToCheck.filter((attribute) => utils.object.keys(returnObject).find((key) => attribute === key || attribute.startsWith(key + ".")));
}
await Promise.all(attributesToCheck.map(async (key) => {
const check = async (): Promise<void> => {
Expand Down

0 comments on commit 1328a51

Please sign in to comment.