JKHeadley / rest-hapi

🚀 A RESTful API generator for Node.js

Home Page:https://resthapi.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

associations validation

ahmedsoliman64 opened this issue · comments

**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

@ahmedsoliman64 Thanks for pointing this out!