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

Form::PATTERN doesn't allow for case-insensitive checks #185

Closed
renekliment opened this issue Jul 24, 2018 · 4 comments · Fixed by #187
Closed

Form::PATTERN doesn't allow for case-insensitive checks #185

renekliment opened this issue Jul 24, 2018 · 4 comments · Fixed by #187

Comments

@renekliment
Copy link
Contributor

Version: 2.4.x

Bug Description

Hi! I'm trying to perform a case-insensitive pattern validation using the Form::PATTERN form rule, but it seems the functionality isn't there.

  1. Both the PHP & JS code puts stuff before and after the regexp so using global modifiers is not possible. Moreover, JS doesn't support in-line regexp modifiers.
  2. It seems that Form::REGEXP used to exist in the past (but was removed) that could do this. Also, in netteForms.js, the handler function is still there.

Steps To Reproduce

$control->addRule(Form::PATTERN, 'Invalid file extension.', "(.*)\.(txt|md)");

Expected Behavior

To be able to use the i modifier. Or to be able to achieve the same behavior in a reasonable way.

Possible Solution

Not sure. I don't know the reason behind removing Form::REGEXP and it seems weird to me that people wouldn't want to use this. Do they write new validation rules instead?

@dg
Copy link
Member

dg commented Jul 24, 2018

It should be compatible with HTML5 attribute pattern

@renekliment
Copy link
Contributor Author

@dg I see, makes sense. What was the reason for removing Form::REGEXP then? Duplicity? If that's the case and the only reason, I believe it would be beneficial to bring it back, because it provides an added value. I can open a PR if it makes sense.

@dg
Copy link
Member

dg commented Jul 25, 2018

Yes, duplicity.

Because REGEXP had a little different syntax, it might be better to add new PATTERN_ICASE (or similar name).

@renekliment
Copy link
Contributor Author

@dg Okay, I'll try to cook up a PR. Thank you.

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

Successfully merging a pull request may close this issue.

2 participants