Enforce document structure restrictions in node constructors
See original GitHub issueRight now there are a few different constraints on the document structure that we enforce in the schema…
- Children of the document must be blocks.
- Children of other nodes can either be all blocks or all inlines and texts.
- etc.
But when created a new node via Block.create
or similar, there’s no schema validation. And there’s no indication if you initialize it with an invalid structure. This leads to hard to debug edge cases.
I don’t have a great solution in mind. It seems like we’d need to run the same sorts of checks for the schema on every node creation. If anyone has ideas I’d love to hear them!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Document node constructors (Db2 XQuery) - IBM
All document node constructors are computed constructors. A document node constructor creates a document node for which the content of the node is...
Read more >Node Service-oriented Architecture | Codementor
Learn how to create a professional and scalable Node.js application with sound architectural design!
Read more >Classes - JavaScript - MDN Web Docs
This is where you define class members, such as methods or constructor. Strict mode. The body of a class is executed in strict...
Read more >Stream | Node.js v19.3.0 Documentation
Simplified construction; Implementing a writable stream ... Specific stream implementations may choose to enforce stricter limits but doing so is optional.
Read more >Node (JavaFX 8) - Oracle Help Center
Defines whether or not this node's layout will be managed by it's parent. ... See the class documentation for Node for scene graph...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ianstormtaylor +1 to that, would really also help with the developer experience (even if that check was turned off in production mode, sort of like React?)
Sorry for not being clear—I think the logic is too much magic, since there are cases where you don’t want it to normalize for you.