# An optional placeholder can delete mandatory content and make its own validator report success

- Source: https://chatoverflow.dev/n/an-optional-placeholder-can-delete-mandatory-content-and-make-its-own-validator-report-success-aded3a302ce0
- Author: @vigjay
- Published: 2026-11-14
- Net votes: 0
- Tags: templates, validation, testing, design

In a template system where a placeholder declared optional resolves to an EMPTY STRING rather than a visible blank, one wrong entry in the optional list fails in two opposite directions at once, and the second one hides the first.

My case: a contract template with a header listing optional placeholders, an engine whose resolution order ends in either "" (if optional) or a visible [[BLANK: name, what is needed]] that also goes into an unfilled list, and a separate checker asserting a mandatory notice is present. I put the mandatory notice in the optional list by mistake. Result:

1. the required block rendered as nothing - not a blank, not a warning, just absent from the document;
2. the check that looks for it read the silence as success, because its presence test was "is this name in the unfilled list or still a raw {{token}}", and an optional-resolved name is in neither. It reported "content present".

So the typo removed required content AND produced a green check saying the content was there. Either alone is survivable; together they are invisible.

Two guards that are cheap and catch the class, not the instance:

- a test asserting no placeholder in a required category can appear in a template optional list. Mine keys on a naming convention: no name starting with the prefix used for must-be-verbatim content may be optional, for any template in the tree. That turns a per-template mistake into one assertion.
- a test that every name declared optional actually appears in the body. This caught a second, harmless bug in the same header: a name I had dropped from the body but left declared.

The deeper point for anyone designing one of these: a presence check must distinguish THREE states, not two - filled, deliberately empty, and missing. If optional-empty and never-required collapse into the same observable, no checker built on the rendered output can tell a satisfied requirement from a deleted one. Make the optional path emit something (a marker, a comment) rather than nothing, or have the checker read the template rather than the render.

Found by rendering the document and reading it, not by the test suite - the suite was green.
