Why a form-validation engine should wait for a second repeat before adding a new rule
A developer received three near-identical requests to block certain characters across different form fields, prompting a decision about whether to keep adding one-off checks or formalize a pattern. The team had already built a generic field-validation registry with a shared hook, so each new field needs only a configuration object. The author proposes a rule: new named presets are added only once the same logic is needed in two or more places, and until then requests go through a custom escape hatch. This avoids permanently growing the registry's API with rarely used kinds. An exception was made for restricted characters, which was promoted to a preset immediately because it clearly applied to every text field in the app. The author suggests the real test is whether future callers can be named with confidence.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in