JKHeadley / rest-hapi

🚀 A RESTful API generator for Node.js
https://resthapi.com
MIT License
1.19k stars 152 forks source link

associations validation #160

Open ahmedsoliman64 opened 5 years ago

ahmedsoliman64 commented 5 years ago

No validation to make sure that associations already exist Create new model with ref to other model not validated if already exist or not

To Reproduce Steps to reproduce the behavior:

  1. Create two models A and B. 2- Add ref in model A of type ObjectId to model B 3- try to call the post method to create new document from model A with a random ObjectId value in the ref field. which refer to model B.

Expected behavior a validation errors with message Model B is not exist

Actual behavior Error 500 will be thrown

JKHeadley commented 5 years ago

@ahmedsoliman64 Thanks for pointing this out!