MishkaCmsCore. Runtime. Resources. Validations. ParentBelongsToDocument
(Mishka CMS Core v0.0.1)
Copy Markdown
View Source
The two things a reply's parent has to be.
Learned from MishkaBlog.Comment, which carries the same pair for the same reasons and has had
longer to find out they were needed:
- On the same document. A reply that answers a note about another page is not an answer; it
is a note that has been moved somewhere nobody will look for it, silently, because the thread
it appears in is chosen by
document_idand not by the parent. - Not itself. A row that is its own parent is a cycle, and every renderer that walks the thread hangs on it. A form cannot produce this by hand, but a stale id or a copied payload can.
Both are checked here rather than in the panel because the panel is not the only way in — the JSON:API and a seed reach the same actions.
Nothing is checked when parent_comment_id is absent: a note that starts a thread is the common
case and has no parent to be wrong about.