xmartlabs / Eureka

Elegant iOS form builder in Swift
https://eurekacommunity.github.io
MIT License
11.78k stars 1.33k forks source link

The regular expression in RuleEmail does not allow some valid special characters #2159

Closed mstralka closed 3 years ago

mstralka commented 3 years ago

Eureka's enum RegExprPattern.EmailAddress currently looks like this:

^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-+]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z‌​]{2,})$

According to Valid Characters for Email Addresses: The Complete List, the username of an email address may contain apostrophes, question marks, exclamation points, and some other special characters: image

I propose changing the email address regular expression to:

^[_A-Za-z0-9-+!?#$%'`*/=~^{}|]+(\\.[_A-Za-z0-9-+!?#$%'`*/=~^{}|]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*(\\.[A-Za-z‌​]{2,})$
mats-claassen commented 3 years ago

Makes sense. Could you create a PR with this change and also updating ValidationsTests.swift by either updating testRuleEmail, or adding a new test with some simple validations?