Title: Signal Forms: Consider allowing validation in FormValueControl · Issue #65769 · angular/angular · GitHub
Open Graph Title: Signal Forms: Consider allowing validation in FormValueControl · Issue #65769 · angular/angular
X Title: Signal Forms: Consider allowing validation in FormValueControl · Issue #65769 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description The signal forms doco on Value transformation contains: ...and handle input events to parse user input back to the storage format but any time use...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description The signal forms doco on Value transformation contains: ...and handle input events to parse user input bac...
X Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description The signal forms doco on Value transformation contains: ...and handle input events to parse user input bac...
Opengraph URL: https://github.com/angular/angular/issues/65769
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Signal Forms: Consider allowing validation in FormValueControl","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\nforms\n\n### Description\n\nThe signal forms doco on [Value transformation](https://angular.dev/guide/forms/signals/custom-controls#value-transformation) contains:\n\n> ...and handle input events to parse user input back to the storage format\n\nbut any time user input is parsed there is the chance of invalid input, and hence errors, so I thought I would be able to add some validation there. But the very next section on Validation integration has a big warning:\n\n> IMPORTANT: Don't implement validation logic in your control.\n\nAnd there seems to be a fundamental gap there:\n\n- The control may need to do validation to convert the user input into the model type.\n- The schema validation can only run once the model type is pushed out via `value`.\n\nSomething as simple as the Currency input example in the docs:\n```\nhandleInput(input: string) {\n const num = parseFloat(input.replace(/[^0-9.]/g, ''));\n if (!isNaN(num)) this.value.set(num);\n}\n```\n\n- If the user types a valid number, that is passed up via the `value`.\n- If they then continue typing making it an invalid number, the `value` is not changed and so the control remains valid even through they now have junk in the field.\n- The only options the control has at this point are to clear the value or leave it at the last valid value - there is no way to report what the error is to the parent schema.\n\nI would like to do this:\n```\nhandleInput(input: string) {\n const num = parseFloat(input.replace(/[^0-9.]/g, ''));\n if (isNaN(num)) {\n const msg = `'${input}' is not a valid number.`;\n // pass msg back to framework validation\n } else {\n this.value.set(num);\n }\n}\n```\n\nChanging the `FormUIControl.errors` to a model signal and allowing the control to pass errors back to its parent would seem to be one solution, although I can imagine there are many implementation details with the timing of when validation is run and what happens if both the schema and the control generate errors.\n\nHere's a more complete example for a WidgetControl I am trying to convert from a `ControlValueAccessor` implementation: ([stackblitz](https://stackblitz.com/edit/stackblitz-starters-tk1jhcej?file=src%2Fwidget-input.ts)):\n\n- A custom control that allows a user to type a code-number combination into a text box. The users know almost all of the ones they use and want to speed type them in.\n- I had a similar thing working using `ControlValueAccessor`: the control taps in to the model-to-view and view-to-model chains and inserts a custom Validator as the first validator in the list.\n\n### Proposed solution\n\nPossibly make `FormUiControl.errors` a model signal, allowing the control to pass validation errors back to the framework?\n\n### Alternatives considered\n\nI tried to create a sub-form, but can't see how to get that to work. Ultimately I want the field to act like a any other field in the parent form:\n```\n\u003capp-currency-input [field]=\"userForm.currency\" />\n```","author":{"url":"https://github.com/baarney","@type":"Person","name":"baarney"},"datePublished":"2025-12-02T00:54:34Z","url":"https://github.com/angular/angular/issues/65769"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:2f2d6d2f-811e-2087-19cb-84351bafd72e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9730:2C4BED:3F69200:507A9B1:6B02180A |
| html-safe-nonce | 9c1cd297606fb9d2aceba63f6452421bec21c9090d9fd048a1430eb081e9a620 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NzMwOjJDNEJFRDozRjY5MjAwOjUwN0E5QjE6NkIwMjE4MEEiLCJ2aXNpdG9yX2lkIjoiODA0MjcxODg4MjY3MzUyMDc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 367cc4772158403a4c637896803bc299584c0994a8c2fd8280ed02495e874b52 |
| hovercard-subject-tag | issue:3683482886 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/65769/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d3c09db79f4f829d0543fe1e84b21418d0069cccd1f25d952a79196a3748a96e/angular/angular/issues/65769 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d3c09db79f4f829d0543fe1e84b21418d0069cccd1f25d952a79196a3748a96e/angular/angular/issues/65769 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? forms Description The signal forms doco on Value transformation contains: ...and handle input events to parse user input bac... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | baarney |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width