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

Comments

Projects
None yet
2 participants
@renekliment
Copy link
Contributor

renekliment commented Jul 24, 2018

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

This comment has been minimized.

Copy link
Member

dg commented Jul 24, 2018

It should be compatible with HTML5 attribute pattern

@renekliment

This comment has been minimized.

Copy link
Contributor

renekliment commented Jul 25, 2018

@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor

renekliment commented Jul 25, 2018

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

@dg dg closed this in #187 Jul 27, 2018

dg added a commit that referenced this issue Jul 27, 2018

dg added a commit that referenced this issue Jul 27, 2018

dg added a commit that referenced this issue Jul 27, 2018

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