how's it going. I am trying to validate a foreign key on a record insert, but to no avail. My model has associated the property:
"options": {"validate": true }
When doing a POST and passing it an invalid ID of the model that the relation refers to, it lets me insert it without a problem.
How can I validate the existence of the referenced IDs?
Not finding a way to automatically do validation at the model level as it is a relationship, I had to do it manually in the file by
neighborhood.js
adding a hook inbefore save
.Here is a solution to the problem. I hope it serves you.