Skip to content

feat(forms): switch to RegExp in pattern validator #62671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: prototype/signal-forms
Choose a base branch
from

Conversation

kirjs
Copy link
Contributor

@kirjs kirjs commented Jul 16, 2025

No description provided.

No other libraries use string patterns for validation
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: forms labels Jul 16, 2025
@ngbot ngbot bot added this to the Backlog milestone Jul 16, 2025

metadata(path, PATTERN, (ctx) => {
const result = reactivePatternValue(ctx);
if (result === undefined) {
return [];
}
return [result];
return [result.source];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we switch the PATTERN metadata to be an array of RegExp?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the PATTERN metadata intended to be used?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just to give the user some way to get the list of patterns that are being applied to the field. They could use it to set the pattern attribute if they want, or to show a "hint" message under the input like "your username must be formatted like: ...".

Most users probably don't care too much about it, but for things like required and min, the metadata is very important because it can be used to show the required * or set the min attribute on the input. For consistency we give you the pattern as metadata too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: forms detected: feature PR contains a feature commit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants