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 @@