Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Set regex as const outside of the function
Browse files Browse the repository at this point in the history
  • Loading branch information
rememberlenny committed Jun 23, 2017
1 parent 3701c8e commit 41addee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions static_src/util/validators.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;

export function validateInteger(options) {
const { max, min } = options || {};
return function _validateInteger(text) {
Expand Down Expand Up @@ -41,8 +43,7 @@ export function validateString() {

export function validateEmail() {
return function _validateEmail(value, name) {
const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (!(emailRegex).test(value)) {
if (!(EMAIL_REGEX).test(value)) {
const nameString = (name ? `in ${name} ` : '');
return {
message: `The value entered ${nameString}is not a valid e-mail address`
Expand Down

0 comments on commit 41addee

Please sign in to comment.