Skip to content

Commit

Permalink
Closes #387: validation username and group name in UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jendib committed Mar 25, 2020
1 parent e614cb4 commit 2c5ff64
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs-web/src/main/webapp/src/app/docs/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ angular.module('docs',
} else {
// Or else determine the language based on the user's browser
$translateProvider.determinePreferredLanguage();
if (!$translateProvider.use()) {
$translateProvider.use('en');
}
}

// Configuring Timago
Expand Down
3 changes: 2 additions & 1 deletion docs-web/src/main/webapp/src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@
"email": "Must be a valid e-mail",
"password_confirm": "Password and password confirmation must match",
"number": "Number required",
"no_space": "Spaces and colons are not allowed"
"no_space": "Spaces and colons are not allowed",
"alphanumeric": "Only letters and numbers are allowed"
},
"action_type": {
"ADD_TAG": "Add a tag",
Expand Down
3 changes: 2 additions & 1 deletion docs-web/src/main/webapp/src/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,8 @@
"email": "Doit être une adresse e-mail valide",
"password_confirm": "Le mot de passe et sa confirmation doivent être identiques",
"number": "Nombre requis",
"no_space": "Les espaces ne sont pas autorisés"
"no_space": "Les espaces ne sont pas autorisés",
"alphanumeric": "Seuls les lettres et les chiffres sont autorisés"
},
"action_type": {
"ADD_TAG": "Ajouter un tag",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ <h2 ng-show="!isEdit()" translate="settings.group.edit.add_group_title"></h2>
<label class="col-sm-2 control-label" for="inputName">{{ 'settings.group.edit.name' | translate }}</label>
<div class="col-sm-7">
<input name="name" type="text" id="inputName" required class="form-control"
ui-validate="{ space: '!$value || $value.indexOf(\' \') == -1' }"
ng-pattern="/^[a-zA-Z0-9_]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.group.edit.name' | translate }}" ng-model="group.name"/>
</div>

<div class="col-sm-3">
<span class="help-block" ng-show="editGroupForm.name.$error.required && editGroupForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.minlength && editGroupForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.maxlength && editGroupForm.$dirty">{{ 'validation.too_long' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.space && editGroupForm.$dirty">{{ 'validation.no_space' | translate }}</span>
<span class="help-block" ng-show="editGroupForm.name.$error.pattern && editGroupForm.$dirty">{{ 'validation.alphanumeric' | translate }}</span>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ <h2 ng-show="!isEdit()" translate="settings.user.edit.add_user_title"></h2>
<label class="col-sm-2 control-label" for="inputUserUsername">{{ 'settings.user.edit.username' | translate }}</label>
<div class="col-sm-7">
<input name="userUsername" type="text" id="inputUserUsername" required ng-disabled="isEdit()" class="form-control"
ng-pattern="/^[a-zA-Z0-9_]*$/"
ng-minlength="3" ng-maxlength="50" ng-attr-placeholder="{{ 'settings.user.edit.username' | translate }}" ng-model="user.username"/>
</div>

<div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.userUsername.$error.required && editUserForm.$dirty">{{ 'validation.required' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.minlength && editUserForm.$dirty">{{ 'validation.too_short' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.maxlength && editUserForm.$dirty">{{ 'validation.too_long' | translate }}</span>
<span class="help-block" ng-show="editUserForm.userUsername.$error.pattern && editUserForm.$dirty">{{ 'validation.alphanumeric' | translate }}</span>
</div>
</div>

Expand Down

0 comments on commit 2c5ff64

Please sign in to comment.