Skip to content

Regex /i flag not working #436

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

Closed
9er-tom opened this issue Apr 17, 2025 · 1 comment
Closed

Regex /i flag not working #436

9er-tom opened this issue Apr 17, 2025 · 1 comment

Comments

@9er-tom
Copy link
Contributor

9er-tom commented Apr 17, 2025

Environment

nuxt@3.12.3
vue@3.5.13
@vueform/nuxt@1.7.0
vueform@1.11.0

Reproduction

https://stackblitz.com/edit/github-l6wiwpjl?file=src%2FApp.vue

Describe the bug

'/i' flag in regex validation rule seems to do nothing. As seen in the Stackblitz, entering lowercase 'gnd' in the first TextElement should pass validation, as /i flag is set in regex.

To confirm, the same regex passes on regex101

https://regex101.com/r/Aeyzt1/1

This is especially bizarre, as the /i flag is even showcased in Vueform doc for regex patterns
https://vueform.com/docs/validating-elements#rule-regex

Additional context

seems like the problem lies in the .replace of src/services/validation/rules/regex.js

Executing this

var regex = new RegExp('/^GND$/i'.replace(/^\/|\/[^\/]*$/g, ''));
console.log(regex, regex.test('gnd'));

results in this print: /^GND$/ false
the /i flag is removed by the replacement regex

@9er-tom
Copy link
Contributor Author

9er-tom commented May 6, 2025

Would probably be good to also update documentation on vueform.com accordingly

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

No branches or pull requests

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy