Skip to content

Conversation

@renekliment
Copy link
Contributor

This adds an option to validate form controls like via Form::PATTERN, but with case-insensitive regexp.

  1. Not sure about the name.
  2. Hesitated between an internal common validation method and two child methods - case-sensitive and case-insensitive, but went for this compact solution.

I have a question about the u regexp modifier. It is used in the PHP code, but not in the JS code. However, when I add it to the JS code, the tests break. Do you have more info on this? I thought this would result in enabled case folding on both sides consistently, but ... I don't know, this is not my area of expertise.

Appreciate any pointers / ideas for improvements.
Thank you.

@dg
Copy link
Member

dg commented Jul 25, 2018

I have a question about the u regexp modifier.

Some old browsers (such as PhantomJS used for testing) do not support u modifier.

I fixed it in e3b5529

},

pattern: function(elem, arg, val) {
pattern: function(elem, arg, val, value, modifiers) {
Copy link
Member

Choose a reason for hiding this comment

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

I think that argument caseInsensitive is better than modifiers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok. The same for the PHP bit then?

pub fun xxx(..., bool $caseInsensitive = false) {
    $modifiers = 'u' . ($caseInsensitive ? 'i' : '');
}

Copy link
Member

Choose a reason for hiding this comment

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

Yes

@renekliment
Copy link
Contributor Author

@dg

Some old browsers (such as PhantomJS used for testing) do not support u modifier.

I see. I had thought that PhantomJS uses V8. Silly mistake. Thanks for the explanation.

I fixed it in e3b5529

Dope. I'll rebase on top of that.

Thank you.

@renekliment
Copy link
Contributor Author

@dg Rebased and adjusted. Let me know if you need anything else. Thank you.

@dg
Copy link
Member

dg commented Jul 27, 2018

Great, thanks!

@dg dg merged commit 9561dd8 into nette:master Jul 27, 2018
@renekliment
Copy link
Contributor Author

@dg Dope! Thank you. If you could back-port it to v2.4 that would be even more awesome :-)

@dg
Copy link
Member

dg commented Jul 27, 2018

Done

@renekliment renekliment deleted the pattern_icase branch July 27, 2018 07:50
renekliment added a commit to renekliment/nette-docs that referenced this pull request Aug 22, 2018
dg pushed a commit to nette/docs that referenced this pull request Aug 22, 2018
dg pushed a commit to nette/docs that referenced this pull request Aug 22, 2018
dg pushed a commit to nette/docs that referenced this pull request Dec 27, 2021
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 this pull request may close these issues.

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

2 participants