Skip to content
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

Pattern anchor #664

Open
Prinzhorn opened this issue Nov 9, 2018 · 0 comments
Open

Pattern anchor #664

Prinzhorn opened this issue Nov 9, 2018 · 0 comments

Comments

@Prinzhorn
Copy link

Prinzhorn commented Nov 9, 2018

When reading pattern from HTML it is used directly as a regular expression, which is not correct. The spec says

The compiled pattern regular expression, when matched against a string, must have its start anchored to the start of the string and its end anchored to the end of the string.

This implies that the regular expression language used for this attribute is the same as that used in JavaScript, except that the pattern attribute is matched against the entire value, not just any subset (somewhat as if it implied a ^(?: at the start of the pattern and a )$ at the end).

That means native validation using pattern="\d{5}" only accepts exactly five numbers. But knockout validation will use this as a regular expression, which will accept anything that contains five numbers aynwhere. E.g. foo12345bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant