Apply safe fixes to a Formhaus definition
fix_definitionCall this when validate_definition reports issues with safe fixes, such as a misspelled property name, a missing id or key, an empty label, a one-letter typo in a condition field, a duplicate key nothing refers to or a missing submit…
Instructions
Call this when validate_definition reports issues with safe fixes, such as a misspelled property name, a missing id or key, an empty label, a one-letter typo in a condition field, a duplicate key nothing refers to or a missing submit button. Applies every safe fix and returns { definition, applied, valid, issues }: the repaired definition, the fixes applied in order, and the issues left, the same as validate_definition returns for the repaired definition. Safe fixes never change what the form does beyond the repair. Unsafe fixes, such as pointing a condition at a field two edits away, stay in issues[].fixes for you to check and apply by hand. Save the returned definition, then fix the remaining errors.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| definition | Yes | Formhaus form definition as a JSON object or a JSON string. JSON Schema: https://formhaus.dev/schema/form-definition.json. Top level: id, title, submit { label }, and fields (one step) or steps [{ id, title, fields }]. Field: { key, type, label, validation?, options?, show?, showAny? }. Rules go inside "validation": { required, minLength, maxLength, min, max, pattern, matchField }. Condition: { field, eq | neq | in | notIn | contains | notContains | notEmpty | gt | gte | lt | lte } with exactly one operator, on a field of the same or an earlier step. Optional: lang, messages and labels catalogs, and i18n objects that map texts to translation keys. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| valid | Yes | false when at least one issue has severity "error". | |
| issues | Yes | Issues left after the safe fixes. Errors first, then warnings. Fix them by hand or apply one of their unsafe fixes after checking it. | |
| applied | Yes | Fixes applied, in order. path is where the issue was before the fix. | |
| definition | No | The definition with every safe fix applied. Missing when the input is not a JSON object. |