matteodelabre / mongoose-beautiful-unique-validation

Plugin for Mongoose that turns duplicate errors into regular Mongoose validation errors
MIT License
117 stars 38 forks source link

Custom message detection in nested schema failed - max call stack size exceeded #57

Open knacharam-rythmos opened 6 years ago

knacharam-rythmos commented 6 years ago

Custom message detection in nested schema failed and throwing max call stack size exceeded error.

RCA: Repeating schema instead of schema tree

https://github.com/matteodelabre/mongoose-beautiful-unique-validation/blob/09fa02ecf96a4e8d7935b008a0fa4dabab999fb9/index.js#L71

Fix: Replace below code in line number 71.

    var subtree = collectMessages(tree[key].tree);