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

Commit

Permalink
Fixed issue #20 - now use $translate promises
Browse files Browse the repository at this point in the history
- Fixed issue #20: Error messages shown on submit are
non-understandable, this was fixed using $translate promises instead of
$translate.instant().
- Fixed a few error display on the validationSummary() and
checkFormValidity().
- Merged #27 to add Russian and added it to the main page selection of
language
  • Loading branch information
ghiscoding committed Apr 20, 2015
1 parent d13fcd9 commit d4b5574
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 158 deletions.
22 changes: 5 additions & 17 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ myApp.controller('CtrlValidationDirective', ['$scope', 'validationService', func
}
}
$scope.showValidationSummary = function () {
// the $translate call with promise is a hack to make sure translation locales are loaded
// you probably not have to do that in your local code
$translate('SHOW_VALIDATION_SUMMARY').then(function() {
$scope.displayValidationSummary = true;
});
$scope.displayValidationSummary = true;
}
}]);

Expand All @@ -73,11 +69,7 @@ myApp.controller('Ctrl2forms', ['$scope', 'validationService', function ($scope,
}
}
$scope.showValidationSummary = function () {
// the $translate call with promise is a hack to make sure translation locales are loaded
// you probably not have to do that in your local code
$translate('SHOW_VALIDATION_SUMMARY').then(function() {
$scope.displayValidationSummary = true;
});
$scope.displayValidationSummary = true;
}
}]);

Expand Down Expand Up @@ -114,13 +106,13 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe
.addValidator('input10', 'date_iso|required')
.addValidator('input11', 'date_us_long|required')
.addValidator('input12', 'time')
.addValidator('select1', 'required:alt=' + $translate.instant('CHANGE_LANGUAGE'))
.addValidator('select1', 'alpha|required:alt=' + $translate.instant('CHANGE_LANGUAGE'))
.addValidator({elmName: 'input13', rules: 'min_len:5|max_len:10|alpha_dash_spaces|required', validationErrorTo: ".validation-input13"})
.addValidator('input14', 'alpha|required')
.addValidator('input15', 'alpha|min_len:3|required')
.addValidator('input16', 'match:input15,Password|required')
.addValidator({elmName: 'input17', rules: 'alpha_spaces|exact_len:3|required', debounce: 5000})
.addValidator('input18', 'date_iso_min:1999-12-31|required')
.addValidator('input18', 'date_iso_min:2001-01-01|required')
.addValidator('input19', 'date_us_short_between:11/28/99,12/31/15|required')
.addValidator('area1', 'alpha_dash_spaces|min_len:15|required');

Expand All @@ -131,11 +123,7 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe
};

$scope.showValidationSummary = function () {
// the $translate call with promise is a hack to make sure translation locales are loaded
// you probably not have to do that in your local code
$translate('SHOW_VALIDATION_SUMMARY').then(function() {
$scope.displayValidationSummary = true;
});
$scope.displayValidationSummary = true;
}

$scope.submitForm = function() {
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghiscoding.angular-validation",
"version": "1.3.17",
"version": "1.3.18",
"authors": [
"Ghislain B."
],
Expand Down
5 changes: 3 additions & 2 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Angular-Validation change logs
1.3.12 (2015-04-04): Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
1.3.13 (2015-04-06) Fixed $translate delay issue when using external JSON files
1.3.14 (2015-04-07) Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators.
1.3.15 (2015-04-08) Fixed #23 If multiple forms exist in the app the errors in 1 form affect validation in the other
1.3.15 (2015-04-08) Fixed issue #23 If multiple forms exist in the app the errors in 1 form affect validation in the other
1.3.16 (2015-04-09) Accept Merge #3 Fixed removeFromValidationSummary to also remove from 'local' array
1.3.17 (2015-04-11) Added global `$scope.$validationOptions` object, for now only has the `debounce` property that be used by both the Directive and Service.
1.3.17 (2015-04-11) Added global `$scope.$validationOptions` object, for now only has the `debounce` property that be used by both the Directive and Service.
1.3.18 (2015-04-19) Fixed issue #20 - Error messages shown on submit are non-understandable, this was fixed using $translate promises instead of $translate.instant(). Fixed a few error display on the validationSummary() and checkFormValidity(). Also merged #27 to add Russian
10 changes: 5 additions & 5 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ <h1>Angular-Validation Directive|Service (ghiscoding)</h1>

<span class="text-info"><strong>{{'CHANGE_LANGUAGE' | translate}}: </strong></span>
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default" ng-click="switchLanguage('en')">English</button>
<button type="button" class="btn btn-default" ng-click="switchLanguage('es')">Español</button>
<button type="button" class="btn btn-default" ng-click="switchLanguage('fr')">Français</button>
<button type="button" class="btn btn-default" ng-click="switchLanguage('no')">Norsk</button>
<button type="button" class="btn btn-default" title="English" ng-click="switchLanguage('en')">EN</button>
<button type="button" class="btn btn-default" title="Español" ng-click="switchLanguage('es')">ES</button>
<button type="button" class="btn btn-default" title="Français" ng-click="switchLanguage('fr')">FR</button>
<button type="button" class="btn btn-default" title="Norsk" ng-click="switchLanguage('no')">NO</button>
<button type="button" class="btn btn-default" title="Pусский" ng-click="switchLanguage('ru')">RU</button>
</div>

<span class="text-info" style="margin-left: 20px"><strong>Type: </strong></span>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ghiscoding.angular-validation",
"version": "1.3.17",
"version": "1.3.18",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "app.js",
Expand Down
11 changes: 7 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Angular Validation (Directive / Service)
`Version: 1.3.17`
`Version: 1.3.18`
### Form validation after user inactivity of default 1sec. (customizable timeout)

Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest!
Expand Down Expand Up @@ -30,7 +30,7 @@ For more explanations, see the question answered: [Why Use It?](#whyuseit)
* [Changelog](#changelog)
* [Demo - Plunker](#plunker)
* [Dependencies](#dependencies)
* [Form Submit and Validation](#submit)
* [Form Submit and Validation - checkFormValidity()](#submit)
* [Global Options](#global-options)
* [Install (bower)](#install)
* [Include it in your app project](#project)
Expand All @@ -55,13 +55,15 @@ You can transform this:
<span ng-show="userForm.username.$error.maxlength" class="help-block">Username is too long.</p>
</div>
```
into this:
into this (errors will display in your own locale):
```html
<input type="text" name="username" ng-model="user.username"
validation="min_len:3|max_len:8|required" />
```
The Angular-Validation will create by itself the necessary error message. Now imagine your form with 10 inputs, using the Angular-Validation will end up using 10 lines of code, while on the other hand using the default of Angular will give you 30 lines of code... so what are you waiting for? Use Angular-Validation!!! :)

Let's not forget the [Validation summary](#validation-summary) which is also a great and useful way of displaying your errors to the user.

<a name="install"></a>
Install
-----
Expand Down Expand Up @@ -496,4 +498,5 @@ License
* [1.3.14](https://github.com/ghiscoding/angular-validation/pull/19) `2015-04-07` Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators
* [1.3.15](https://github.com/ghiscoding/angular-validation/commit/24037e4b2e22658e7e2011c022ba4cca26f391d9) `2015-04-08` Fixed #23 If multiple forms exist in the app the errors in 1 form affect validation in the other
* [1.3.16](https://github.com/ghiscoding/angular-validation/commit/6c419d45bdb00341416d91199003d827259bd5da) `2015-04-09` Accept Merge #3 Fixed removeFromValidationSummary to also remove from 'local' array
* [1.3.17](https://github.com/ghiscoding/angular-validation/commit/1283a3a7435c70ec0a355ee273c8479e4b9bdabf) `2015-04-11` Added global `$scope.$validationOptions` [Global Options](#global-options) object, for now only has the `debounce` property that be used by both the Directive and Service.
* [1.3.17](https://github.com/ghiscoding/angular-validation/commit/1283a3a7435c70ec0a355ee273c8479e4b9bdabf) `2015-04-11` Added global `$scope.$validationOptions` [Global Options](#global-options) object, for now only has the `debounce` property that be used by both the Directive and Service.
* [1.3.18]() `2015-04-19` Fixed issue #20 - Error messages shown on submit are non-understandable, this was fixed using $translate promises instead of $translate.instant(). Fixed a few error display on the validationSummary() and checkFormValidity(). Also merged #27 to add Russian
Loading

0 comments on commit d4b5574

Please sign in to comment.