Title: pattern validation for optional fields · Issue #66539 · angular/angular · GitHub
Open Graph Title: pattern validation for optional fields · Issue #66539 · angular/angular
X Title: pattern validation for optional fields · Issue #66539 · angular/angular
Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description optional fields can be represented by foo: string | null; the pattern signature is the following and we get a ts(2345) error. export function patt...
Open Graph Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description optional fields can be represented by foo: string | null; the pattern signature is the following and we ge...
X Description: Which @angular/* package(s) are relevant/related to the feature request? forms Description optional fields can be represented by foo: string | null; the pattern signature is the following and we ge...
Opengraph URL: https://github.com/angular/angular/issues/66539
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"pattern validation for optional fields","articleBody":"### Which @angular/* package(s) are relevant/related to the feature request?\n\nforms\n\n### Description\n\noptional fields can be represented by\n\n```ts\nfoo: string | null;\n```\n\nthe pattern signature is the following and we get a ts(2345) error.\n\n```ts\nexport function pattern\u003cTPathKind extends PathKind = PathKind.Root\u003e(\n path: SchemaPath\u003cstring, SchemaPathRules.Supported, TPathKind\u003e,\n pattern: RegExp | LogicFn\u003cstring | undefined, RegExp | undefined, TPathKind\u003e,\n config?: BaseValidatorConfig\u003cstring, TPathKind\u003e,\n) {\n```\n\n### Proposed solution\n\n```ts\nexport function pattern\u003cTPathKind extends PathKind = PathKind.Root\u003e(\n path: SchemaPath\u003cstring | null, SchemaPathRules.Supported, TPathKind\u003e,\n pattern: RegExp | LogicFn\u003cstring | null | undefined, RegExp | undefined, TPathKind\u003e,\n config?: BaseValidatorConfig\u003cstring | null, TPathKind\u003e,\n) {\n```\n\n```ts\nexport function pattern\u003cTValue extends string | null, TPathKind extends PathKind = PathKind.Root\u003e(\n path: SchemaPath\u003cTValue , SchemaPathRules.Supported, TPathKind\u003e,\n pattern: RegExp | LogicFn\u003cTValue | undefined, RegExp | undefined, TPathKind\u003e,\n config?: BaseValidatorConfig\u003cTValue , TPathKind\u003e,\n) {\n```\n\n### Alternatives considered\n\nAlternative is to just have it as string and use `''`","author":{"url":"https://github.com/cheng93","@type":"Person","name":"cheng93"},"datePublished":"2026-01-14T10:17:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/66539/angular/issues/66539"}
| 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:e8c83574-6ac3-0d0f-3fdc-061e7281e4be |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DB6A:13A5D2:321E7D:424DAB:696B669D |
| html-safe-nonce | cc4a50a16981e928d2c21df4015da02aebef30f2ef4386c972c8e8fc4e6ad06f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQjZBOjEzQTVEMjozMjFFN0Q6NDI0REFCOjY5NkI2NjlEIiwidmlzaXRvcl9pZCI6IjQ0MTI4MDk1NzgxODkzODMzMjUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 18b07eddf6864992f646d2cd42aac43ad27d733b2425529fe6bf7f3b06964234 |
| hovercard-subject-tag | issue:3812528161 |
| 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/66539/issue_layout |
| twitter:image | https://opengraph.githubassets.com/6e25d97c3a912187dd52dde88c34800e2b274946be374d0632ef0ae1fcc94fd8/angular/angular/issues/66539 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/6e25d97c3a912187dd52dde88c34800e2b274946be374d0632ef0ae1fcc94fd8/angular/angular/issues/66539 |
| og:image:alt | Which @angular/* package(s) are relevant/related to the feature request? forms Description optional fields can be represented by foo: string | null; the pattern signature is the following and we ge... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | cheng93 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width