mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
updates for email validations.
This commit is contained in:
parent
f31e4f3608
commit
0ba342ca96
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
@ -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,}))$/);
|
||||
|
||||
})();
|
@ -29,7 +29,7 @@
|
||||
<div class="form-group">
|
||||
<label for="email" class="col-sm-3 control-label">// 'email' | tr //:</label>
|
||||
<div class="col-sm-7">
|
||||
<input type="email" class="form-control" id="email" ng-model="user.email" name="uEmail" required>
|
||||
<input type="text" class="form-control" id="email" ng-model="user.email" name="uEmail" required email>
|
||||
<div class="error-message" ng-messages="form.uEmail.$touched && form.uEmail.$error">
|
||||
<span ng-message="required">// 'email_is_required' | tr //</span>
|
||||
<span ng-message="email">// 'email_content_illegal' | tr //</span>
|
||||
|
@ -24,7 +24,7 @@
|
||||
<div class="form-group">
|
||||
<label for="email" class="col-sm-3 control-label">// 'email' | tr //:</label>
|
||||
<div class="col-sm-7">
|
||||
<input type="email" class="form-control" id="email" ng-model="user.email" ng-model-options="{ debounce: 500 }" ng-change="vm.reset()" name="uEmail" required data-target="email">
|
||||
<input type="text" class="form-control" id="email" ng-model="user.email" ng-model-options="{ debounce: 500 }" ng-change="vm.reset()" name="uEmail" required data-target="email" email>
|
||||
<div class="error-message">
|
||||
<div ng-messages="(form.$submitted || form.uEmail.$touched) && form.uEmail.$error">
|
||||
<span ng-message="required">// 'email_is_required' | tr //</span>
|
||||
|
@ -127,6 +127,7 @@
|
||||
<script src="/static/resources/js/components/validator/user-exist.validator.js"></script>
|
||||
<script src="/static/resources/js/components/validator/invalid-chars.validator.js"></script>
|
||||
<script src="/static/resources/js/components/validator/project-name.validator.js"></script>
|
||||
<script src="/static/resources/js/components/validator/email.validator.js"></script>
|
||||
|
||||
<script src="/static/resources/js/components/search/search.module.js"></script>
|
||||
<script src="/static/resources/js/components/search/search.directive.js"></script>
|
||||
|
@ -45,12 +45,11 @@
|
||||
<div class="form-group">
|
||||
<label for="email" class="col-sm-3 control-label">// 'email' | tr //:</label>
|
||||
<div class="col-sm-7">
|
||||
<input type="email" class="form-control" id="email" ng-model="user.email" name="uEmail" ng-model-options="{ updateOn: 'blur' }" required user-exists data-target="email" maxlength="50">
|
||||
<div class="error-message" ng-messages="(form.$submitted || form.uEmail.$touched) &&form.uEmail.$error">
|
||||
<input type="text" class="form-control" id="email" ng-model="user.email" name="uEmail" ng-model-options="{ updateOn: 'blur' }" required user-exists data-target="email" email>
|
||||
<div class="error-message" ng-messages="(form.$submitted || form.uEmail.$touched) && form.uEmail.$error">
|
||||
<span ng-message="required">// 'email_is_required' | tr //</span>
|
||||
<span ng-message="email">// 'email_content_illegal' | tr //</span>
|
||||
<span ng-message="userExists">// 'email_has_been_taken' | tr //</span>
|
||||
<span ng-message="maxlength">// 'email_is_too_long' | tr //</span>
|
||||
</div>
|
||||
<p class="help-block small-size-fonts">// 'email_desc' | tr //</p>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user