{"id":19354560,"url":"https://github.com/weisjohn/mongoose-reference-validator","last_synced_at":"2025-10-07T01:45:34.496Z","repository":{"id":57302232,"uuid":"39544875","full_name":"weisjohn/mongoose-reference-validator","owner":"weisjohn","description":"validator for external reference documents","archived":false,"fork":false,"pushed_at":"2015-07-23T05:28:06.000Z","size":136,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-27T19:54:17.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/mongoose-reference-validator","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/weisjohn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-23T04:02:22.000Z","updated_at":"2024-06-22T02:57:47.000Z","dependencies_parsed_at":"2022-09-20T16:41:44.859Z","dependency_job_id":null,"html_url":"https://github.com/weisjohn/mongoose-reference-validator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/weisjohn/mongoose-reference-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-reference-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-reference-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-reference-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-reference-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/weisjohn","download_url":"https://codeload.github.com/weisjohn/mongoose-reference-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/weisjohn%2Fmongoose-reference-validator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263388882,"owners_count":23459294,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T05:02:34.297Z","updated_at":"2025-10-07T01:45:29.461Z","avatar_url":"https://github.com/weisjohn.png","language":"JavaScript","readme":"# mongoose-reference-validator\n\nvalidator for external reference documents\n\n### usage\n\nschema setup\n\n```javascript\nvar mongoose = require('mongoose');\nvar ObjectId = mongoose.Schema.Types.ObjectId;\nvar mrf = require('mongoose-reference-validator');\n\nvar user = new mongoose.Schema({ name: String });\nmongoose.model('user', user);\n\nvar car = new mongoose.Schema({\n    name: String,\n    driver : { type: ObjectId, ref: 'user' },\n});\nmrf(car);\nmongoose.model('car', car);\n```\n\ndocument interaction\n\n```javascript\nvar jetta = new car({ name : \"Jetta\", user : user._id });\njetta.save(function(err, doc) {\n    if (err \u0026\u0026 err.errors.driver.message) {\n        console.log('user._id was invalid');\n        console.log(err.errors.driver.message); // driver does not exist\n    }\n});\n```\n\nThe [validator](http://mongoosejs.com/docs/validation.html#update-validators) will run when being saved, however, you can also run while [updating](http://mongoosejs.com/docs/validation.html#update-validators). \n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-reference-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweisjohn%2Fmongoose-reference-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweisjohn%2Fmongoose-reference-validator/lists"}