Skip to content

Commit f8dc5f5

Browse files
authored
Fix email validation broken for new domains (#20)
1 parent 549247c commit f8dc5f5

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ const addValidationRule = (name, func) => {
459459
const withFormsy = Wrapper;
460460

461461
const deprecatedWrapper = (Component) => {
462+
// eslint-disable-next-line no-console
462463
console.warn('Wrapper has been renamed to withFormsy. Importing Wrapper from formsy-react is depreacted and will be removed in the future. Please rename your Wrapper imports to withFormsy.');
463464

464465
return withFormsy(Component);

src/validationRules.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const validations = {
1818
return isEmpty(value);
1919
},
2020
isEmail(values, value) {
21-
return validations.matchRegexp(values, value, /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i);
21+
// Regex from http://emailregex.com/
22+
return validations.matchRegexp(values, value, /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i);
2223
},
2324
isUrl(values, value) {
2425
return validations.matchRegexp(values, value, /^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/i);

tests/Rules-isEmail-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ export default {
4949

5050
},
5151

52+
'should pass with new long domains': function (test) {
53+
54+
const form = TestUtils.renderIntoDocument(<TestForm inputValue="tickets@now.diamonds"/>);
55+
const inputComponent = TestUtils.findRenderedComponentWithType(form, TestInput);
56+
test.equal(inputComponent.isValid(), true);
57+
test.done();
58+
59+
},
60+
5261
'should pass with an undefined': function (test) {
5362

5463
const form = TestUtils.renderIntoDocument(<TestForm inputValue={undefined}/>);

0 commit comments

Comments
 (0)