Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/mongoose-id-validator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion lib/id-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ IdValidator.prototype.validateSchema = function (
}
} else if (schemaType.options && schemaType.options.refPath) {
refModelPath = schemaType.options.refPath
console.log("[mongoose-id-validator] schemaType.options: ", schemaType.options)
console.log("[mongoose-id-validator] schemaType: refPath", schemaType.options.refPath)
if (schemaType.options.refConditions) {
conditions = schemaType.options.refConditions
}
Expand Down Expand Up @@ -91,9 +93,17 @@ IdValidator.prototype.validateSchema = function (
})
}
var localRefModelName = refModelName
/*console.log("[mongoose-id-validator] REF_PATH_NAME: ", refModelPath)
console.log("[mongoose-id-validator] THIS: ", this)
console.log("[mongoose-id-validator] SCHEMA: ", schemaType)
console.log("[mongoose-id-validator] PATH: ", path)*/

if (refModelPath) {
localRefModelName = this[refModelPath]
const refModelPathSplits = refModelPath.split('.')
if(refModelPathSplits.length > 1) localRefModelName = this[refModelPathSplits[refModelPathSplits.length-1]]
else localRefModelName = this[refModelPath]
}
// console.log("[mongoose-id-validator] REF_Model_NAME: ", localRefModelName)

return validateFunction(this, connection, localRefModelName,
value, conditionsCopy, resolve, reject, allowDuplicates)
Expand Down Expand Up @@ -123,6 +133,7 @@ function executeQuery (query, conditions, validateValue, resolve, reject) {

function validateId (
doc, connection, refModelName, value, conditions, resolve, reject) {

if (value == null) {
resolve(true)
return
Expand Down
Loading