diff --git a/src/ui/static/resources/js/components/validator/email.validator.js b/src/ui/static/resources/js/components/validator/email.validator.js new file mode 100644 index 000000000..c7421bfa8 --- /dev/null +++ b/src/ui/static/resources/js/components/validator/email.validator.js @@ -0,0 +1,44 @@ +/* + Copyright (c) 2016 VMware, Inc. All Rights Reserved. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ +(function() { + + 'use strict'; + + angular + .module('harbor.validator') + .directive('email', email); + + email.$inject = ['EMAIL_REGEXP']; + + function email(EMAIL_REGEXP) { + var directive = { + 'require' : 'ngModel', + 'link': link + }; + return directive; + + function link (scope, element, attrs, ctrl) { + + ctrl.$validators.email = validator; + + function validator(modelValue, viewValue) { + + return EMAIL_REGEXP.test(modelValue); + + } + } + } + +})(); \ No newline at end of file diff --git a/src/ui/static/resources/js/components/validator/validator.config.js b/src/ui/static/resources/js/components/validator/validator.config.js index 187f55008..08e892cdc 100644 --- a/src/ui/static/resources/js/components/validator/validator.config.js +++ b/src/ui/static/resources/js/components/validator/validator.config.js @@ -20,5 +20,7 @@ .module('harbor.validator') .constant('INVALID_CHARS', [",","~","#", "$", "%"]) .constant('PASSWORD_REGEXP', /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?!.*\s).{8,20}$/) - .constant('PROJECT_REGEXP', /^[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*$/); + .constant('PROJECT_REGEXP', /^[a-z0-9](?:-*[a-z0-9])*(?:[._][a-z0-9](?:-*[a-z0-9])*)*$/) + .constant('EMAIL_REGEXP', /^(([^<>()[\]\.,;:\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,}))$/); + })(); \ No newline at end of file diff --git a/src/ui/views/account-settings.htm b/src/ui/views/account-settings.htm index 7389ca51a..55b7c0d24 100644 --- a/src/ui/views/account-settings.htm +++ b/src/ui/views/account-settings.htm @@ -29,7 +29,7 @@
- +
// 'email_is_required' | tr // // 'email_content_illegal' | tr // diff --git a/src/ui/views/forgot-password.htm b/src/ui/views/forgot-password.htm index 389c981b1..ddbbff452 100644 --- a/src/ui/views/forgot-password.htm +++ b/src/ui/views/forgot-password.htm @@ -24,7 +24,7 @@
- +
// 'email_is_required' | tr // diff --git a/src/ui/views/sections/script-include.htm b/src/ui/views/sections/script-include.htm index f07b60649..02679c8ee 100644 --- a/src/ui/views/sections/script-include.htm +++ b/src/ui/views/sections/script-include.htm @@ -127,6 +127,7 @@ + diff --git a/src/ui/views/sign-up.htm b/src/ui/views/sign-up.htm index 4bae1a5d0..76bb5b7be 100644 --- a/src/ui/views/sign-up.htm +++ b/src/ui/views/sign-up.htm @@ -45,12 +45,11 @@
- -
+ +
// 'email_is_required' | tr // // 'email_content_illegal' | tr // // 'email_has_been_taken' | tr // - // 'email_is_too_long' | tr //

// 'email_desc' | tr //