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

Commit d4b5574

Browse files
committed
Fixed issue #20 - now use $translate promises
- 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
1 parent d13fcd9 commit d4b5574

13 files changed

+219
-158
lines changed

app.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,7 @@ myApp.controller('CtrlValidationDirective', ['$scope', 'validationService', func
5656
}
5757
}
5858
$scope.showValidationSummary = function () {
59-
// the $translate call with promise is a hack to make sure translation locales are loaded
60-
// you probably not have to do that in your local code
61-
$translate('SHOW_VALIDATION_SUMMARY').then(function() {
62-
$scope.displayValidationSummary = true;
63-
});
59+
$scope.displayValidationSummary = true;
6460
}
6561
}]);
6662

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

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

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

133125
$scope.showValidationSummary = function () {
134-
// the $translate call with promise is a hack to make sure translation locales are loaded
135-
// you probably not have to do that in your local code
136-
$translate('SHOW_VALIDATION_SUMMARY').then(function() {
137-
$scope.displayValidationSummary = true;
138-
});
126+
$scope.displayValidationSummary = true;
139127
}
140128

141129
$scope.submitForm = function() {

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghiscoding.angular-validation",
3-
"version": "1.3.17",
3+
"version": "1.3.18",
44
"authors": [
55
"Ghislain B."
66
],

changelog.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Angular-Validation change logs
1616
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.
1717
1.3.13 (2015-04-06) Fixed $translate delay issue when using external JSON files
1818
1.3.14 (2015-04-07) Merge pull request #19 Added norwegian translation and changes to allow user to remove invalid validators.
19-
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
19+
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
2020
1.3.16 (2015-04-09) Accept Merge #3 Fixed removeFromValidationSummary to also remove from 'local' array
21-
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.
21+
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.
22+
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

dist/angular-validation.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ <h1>Angular-Validation Directive|Service (ghiscoding)</h1>
1717

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

2627
<span class="text-info" style="margin-left: 20px"><strong>Type: </strong></span>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ghiscoding.angular-validation",
3-
"version": "1.3.17",
3+
"version": "1.3.18",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "app.js",

readme.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.3.17`
2+
`Version: 1.3.18`
33
### Form validation after user inactivity of default 1sec. (customizable timeout)
44

55
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!
@@ -30,7 +30,7 @@ For more explanations, see the question answered: [Why Use It?](#whyuseit)
3030
* [Changelog](#changelog)
3131
* [Demo - Plunker](#plunker)
3232
* [Dependencies](#dependencies)
33-
* [Form Submit and Validation](#submit)
33+
* [Form Submit and Validation - checkFormValidity()](#submit)
3434
* [Global Options](#global-options)
3535
* [Install (bower)](#install)
3636
* [Include it in your app project](#project)
@@ -55,13 +55,15 @@ You can transform this:
5555
<span ng-show="userForm.username.$error.maxlength" class="help-block">Username is too long.</p>
5656
</div>
5757
```
58-
into this:
58+
into this (errors will display in your own locale):
5959
```html
6060
<input type="text" name="username" ng-model="user.username"
6161
validation="min_len:3|max_len:8|required" />
6262
```
6363
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!!! :)
6464

65+
Let's not forget the [Validation summary](#validation-summary) which is also a great and useful way of displaying your errors to the user.
66+
6567
<a name="install"></a>
6668
Install
6769
-----
@@ -496,4 +498,5 @@ License
496498
* [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
497499
* [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
498500
* [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
499-
* [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.
501+
* [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.
502+
* [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

0 commit comments

Comments
 (0)