# Add Form Validation to a SolidJS App

Yes. An agent adds client-side validation to the sign-up, settings and editor forms of your Solid app, reusing the existing error list, and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-form-validation/solidjs/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the repository into its own cloud sandbox and reads the forms as they are. In an app like solidjs/solid-realworld, `src/pages/Auth.js` renders the sign-in and sign-up form from one component: a `createStore` with `username` and `inProgress`, three inputs (`Username`, `Email`, `Password`) that write to the store on `onChange`, no `required` attributes, `type="text"` on the email field, and a submit handler that calls `login` or `register` from the store and shows whatever the API returns through `src/components/ListErrors.js`. That component renders `Object.keys(props.errors)` as `<li>{key} {props.errors[key]}</li>`, the shape the RealWorld backend sends, such as `{ email: ["can't be blank"] }`. `src/pages/Settings.js` has the same pattern for image URL, username, bio, email and password, and `src/pages/Editor/Editor.js` has title, description, body and a tag input whose `handleAddTag` pushes duplicates into `tagList` and whose publish button is `type="button"` with an `onClick`, so the browser's own form validation never runs. The build is Rollup 2 with `babel-preset-solid`, `solid-js` is `^1.3.3`, and `package.json` has no test runner: `"test": "test"`.

It adds `src/utils/validate.js`, a module of pure functions that take the form state and return errors in exactly the shape `ListErrors` already renders, one key per field with an array of messages, so client-side and server-side errors share a component and a look. Rules are the ones the prompt sets: required fields, an email check, a password length floor, a URL check for the settings image using the `URL` constructor, and non-empty, deduplicated tags in the editor. Each form gets a `createMemo` over its store for the current errors and a `touched` object so a field shows its message after blur or after the first submit attempt, not while the user is still typing their first character. Inputs switch from `onChange` to `onInput` so the memo updates live, get `type="email"` and `required` for assistive technology, and `aria-invalid` plus an `aria-describedby` pointing at their message when invalid. The submit buttons stay disabled while `inProgress` and are additionally disabled while the memo has errors.

Server errors keep their path: the `.catch(errors => setState({ errors }))` branches stay, and the memo merges client errors with the last server errors so a field the API rejected shows the API's message until the user edits it. The editor's `handleAddTag` learns to trim, lowercase and skip a tag already in the list, and the publish button becomes a real submit so Enter works and the browser's validation runs as a fallback. Nothing about `src/store/createAuth.js` or `createAgent.js` changes, because validation is a page concern.

Because there is no test runner, the agent tests the pure module with `node --test` and points `npm test` at it, which keeps the dependency list unchanged. It runs `npm run build` in the sandbox to confirm Rollup and the Solid Babel preset accept the new JSX, serves `public/` and opens the app in its browser to submit each form empty and with a malformed email, checking that messages render in the existing `error-messages` list before it opens the pull request.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add client-side form validation to this SolidJS app. Read the Auth, Settings and Editor pages and the ListErrors component first. Create a pure validation module that returns errors in the same object-of-arrays shape ListErrors renders: required username, email and password on sign-up, a basic email format check, a minimum password length of 8, a valid URL for the settings image when present, and required title, description and body plus non-empty deduplicated tags in the editor. Wire each form with a memo for current errors, per-field touched state so messages appear after blur or a submit attempt, onInput handlers, aria-invalid and aria-describedby, and disabled submit buttons while errors exist. Keep server errors flowing through the same component. Add node --test tests for the validation module and point npm test at them, run the Rollup build, try the forms in the browser, and open a pull request.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request that adds `src/utils/validate.js` and its test file, changes `src/pages/Auth.js`, `src/pages/Settings.js` and `src/pages/Editor/Editor.js`, and edits the `test` script in `package.json`. `ListErrors` is untouched. The description lists the rules per form, shows a screenshot from the sandbox browser of the sign-up form with its messages, and pastes the `node --test` and `rollup -c` output.

The run's record keeps the build output and the browser session, so a reviewer can see the forms rendering and the messages appearing on blur without checking out the branch.

Before merging, a reviewer compares the client rules with what the backend enforces so the two never disagree in a way that lets the form block a value the server would accept, and decides whether the `gh-pages.yml` workflow, which builds on Node 14, should run the new tests, since `node --test` needs a newer Node than that workflow pins.

## Run it on every Linear issue labelled forms

In the console, an automation in the Project that has the repository, with a `linear` trigger on `linear.issue.labeled` and `labels` set to `forms`, starts one run per issue with the issue as context after the prompt; the saved prompt is the whole instruction and the trigger fills in no placeholder. Once the validation module exists, later issues are small: a new rule for a field, a new form such as the comment box on the article page, and each run extends the module, adds a test case and tries the form in the browser before its pull request opens.

From your own tracker, a handler sends one `POST /o/{org}/sessions` with this body and the repository in `resources`, with a `request_id` that is a UUID v5 of the issue id so a repeated webhook returns the run already started. Set a webhook URL on the API key and Rush posts `run.completed` with the `session_url` when the pull request is up.

## Why run it on Rush?

Validation code is easy to write and easy to get subtly wrong in the parts a unit test cannot see: a message that flashes on the first keystroke, a submit button that stays disabled after a server error, a tag input that still accepts duplicates on blur. The agent's sandbox has a browser, so it fills the forms in, tabs through the fields and watches the messages, and that session is part of the run's record a reviewer can replay.

It also respects an older build. The sandbox runs the repository's own Rollup and Babel setup rather than a modern stand-in, so JSX that Solid's preset would reject is caught in the run and not after merge, and the test approach is chosen to add no dependency to a project that has kept its list short.

## Frequently asked questions

### Why not use a form library like Felte or Modular Forms?

Three forms with a dozen fields do not need one, and the app's `ListErrors` already defines how errors look. A pure module plus a memo per form keeps the bundle as it is and keeps the Rollup setup unchanged. If the app grows to many forms, the module's shape makes moving to a library a contained change.

### What happens to the errors the API returns?

They render exactly as before, through the same component. The memo merges client-side errors with the last server response, and a server message for a field clears when that field is edited, so the user is never shown two contradictory messages for one input.

### Does the validation run while the user is typing?

It computes while typing but shows only after a field is blurred or a submit was attempted, through the per-field touched state. The submit button's disabled state follows the live memo, so it enables the moment the last error is fixed.

### How is accessibility handled?

Each invalid input gets `aria-invalid` and an `aria-describedby` that points at its message element, the email field gets `type="email"`, required fields get `required`, and the editor's publish button becomes a real submit so Enter and the browser's own validation work as a fallback for users without JavaScript-driven messages.

### Does this change the Rollup build or the dependencies?

No. The new module is plain JavaScript with Solid primitives the app already imports, tests use Node's built-in runner, and the Rollup config is untouched. The run builds with the repository's own `rollup -c` to prove it.

## More SolidJS jobs

- [Set Up GitHub Actions CI for a SolidJS App](https://getrush.ai/run/add-github-actions-ci/solidjs/)
- [Add Translations to a SolidJS App With @solid-primitives/i18n](https://getrush.ai/run/add-i18n/solidjs/)
- [Add Lighthouse CI to a SolidJS App](https://getrush.ai/run/add-lighthouse-ci/solidjs/)

## The same job on other stacks

- [Add Form Validation to a Vue App](https://getrush.ai/run/add-form-validation/vue/)
- [Add Form Validation to an Angular App](https://getrush.ai/run/add-form-validation/angular/)
- [Add Form Validation to a React Router App](https://getrush.ai/run/add-form-validation/react-router/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
