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

Commit e0d0b76

Browse files
committed
Added isolated scope - Fixed issue #35, #37, #38
- Added possibility to use own isolated scope (issue #37 and #26). - Fixed an implementation issue found from last revision (issue #35). - Fixed email validation (issue #38). - Fixed a performance issue found with onBlur which would run as much validations as there was characters inside the input when onBlur was called (abcdef => would make 6 validations) and this was extremely costly with a Remote validation call. - Update the code of Remote validation to also accept the "As" alias "remote:vm.customRemoteValidation". - Finally added and updated a few Protractor tests to cover all of the above and more.
1 parent 00514f6 commit e0d0b76

31 files changed

+425
-128
lines changed

app.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio
3838
// -- Controller to use Angular-Validation Directive
3939
// -----------------------------------------------
4040
myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService', function ($q, $scope, validationService) {
41-
$scope.$validationOptions = { debounce: 1500 }; // you can change default debounce globally
41+
$scope.$validationOptions = { debounce: 1500, preValidateFormElements: false }; // you can change default debounce globally
4242

4343
$scope.submitForm = function() {
4444
if(new validationService().checkFormValidity($scope.form1)) {
@@ -67,6 +67,9 @@ myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService'
6767
// -- Controller to use Angular-Validation Directive with 2 forms
6868
// ---------------------------------------------------------------
6969
myApp.controller('Ctrl2forms', ['$scope', 'validationService', function ($scope, validationService) {
70+
// on this page we will pre-validate the form and show all errors on page load
71+
$scope.$validationOptions = { debounce: 500, preValidateFormElements: true };
72+
7073
$scope.submitForm = function() {
7174
if(new validationService().checkFormValidity($scope.form01)) {
7275
alert('All good, proceed with submit...');
@@ -103,7 +106,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
103106
// #3 .addValidator({ elmName: 'inputX', rules: 'myRules'})
104107
// the available object properties are the exact same set as the directive except that they are camelCase
105108
myValidation
106-
.setGlobalOptions({ debounce: 1500, scope: $scope })
109+
.setGlobalOptions({ debounce: 1500, scope: $scope, isolatedScope: $scope, preValidateFormElements: false })
107110
.addValidator({ elmName: 'input2', debounce: 3000, rules: 'numeric_signed|required'})
108111
.addValidator('input3', 'float_signed|between_num:-0.6,99.5|required')
109112
.addValidator('input4', 'exact_len:4|regex:YYWW:=^(0[9]|1[0-9]|2[0-9]|3[0-9])(5[0-2]|[0-4][0-9])$:regex|required|integer')

bower.json

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

changelog.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ Angular-Validation change logs
2727
1.3.23 (2015-05-05) Added option to display only last error message instead of all messages at once. Fixed a bug where changing route on View/Controller would make the ValidationSummary fail when coming back to original View/Controller, this bug was associated to the fact that the ValidationSummary kept growing from Controller to Controller, now this ValidationSummary is wipe out as soon as we detect a route change.
2828
1.3.24 (2015-05-17) Replaced all `:param` inside each locale translations with a better standard of {0}, {1}, etc.. like C# `String.Format()`. Added a full Protractor End-to-End test suite (1000+ asserts). Fixed a few minor bugs found with Protractor test cases. Fixed issue #36, bower.json scripts in wrong order.
2929
1.3.25 (2015-05-19) Enhancement #34 to add Remote Validation and updated Protractor to cover this new feature.
30-
1.3.26 (2015-05-30) Added enhancement #35 - PreValidate the Form, display all errors on page load.
30+
1.3.26 (2015-05-30) Added enhancement #35 - PreValidate the Form, display all errors on page load.
31+
1.3.27 (2015-06-02) Added possibility to use own isolated scope (issue #37 and #26). Fixed an implementation issue found from last revision (issue #35). Fixed email validation (issue #38). Fixed a performance issue found with onBlur which would run as much validations as there was characters inside the input when onBlur was called (abcdef => would make 6 validations) and this was extremely costly with a Remote validation call. Revisited the Remote validation to accept also the "As" alias "remote:vm.customRemoteValidation". Finally added and updated a few Protractor tests to cover all of the above and more.

dist/angular-validation.min.js

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

full-tests/app.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ myApp.config(['$routeProvider', '$locationProvider', function ($routeProvider, $
77
.when('/validate-Directive', { templateUrl: 'Directive.html', controller: 'CtrlValidationDirective' })
88
.when('/validate-Service', { templateUrl: 'Service.html', controller: 'CtrlValidationService' })
99
.otherwise({ redirectTo: 'validate-Directive' });
10+
}])
11+
.config(['$compileProvider', function ($compileProvider) {
12+
$compileProvider.debugInfoEnabled(false);
1013
}])
1114
.config(['$translateProvider', function ($translateProvider) {
1215
$translateProvider.useStaticFilesLoader({

full-tests/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h1>Angular-Validation Directive|Service (ghiscoding)</h1>
4545

4646
<!-- Angular-Validation -->
4747
<script type="text/javascript" src="../dist/angular-validation.min.js"></script>
48-
<!--
48+
<!--
4949
<script type="text/javascript" src="../src/validation-directive.js"></script>
5050
<script type="text/javascript" src="../src/validation-service.js"></script>
5151
<script type="text/javascript" src="../src/validation-common.js"></script>

locales/validation/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"INVALID_EXACT_LEN": "Must have a length of exactly {0} characters. ",
3434
"INVALID_FLOAT": "May only contain a positive float value (integer excluded). ",
3535
"INVALID_FLOAT_SIGNED": "May only contain a positive or negative float value (integer excluded). ",
36-
"INVALID_IBAN": "Must a valid IBAN. ",
36+
"INVALID_IBAN": "Must be a valid IBAN. ",
3737
"INVALID_INPUT_MATCH": "Confirmation field does not match specified field \"{0}\". ",
3838
"INVALID_INTEGER": "Must be a positive integer. ",
3939
"INVALID_INTEGER_SIGNED": "Must be a positive or negative integer. ",
@@ -56,6 +56,7 @@
5656
"AREA1": "TextArea: Alphanumeric + Minimum(15) + Required",
5757
"ERRORS": "Errors",
5858
"CHANGE_LANGUAGE": "Change language",
59+
"FORM_PREVALIDATED": "Form is pre-validated",
5960
"INPUT1": "Remote validation - Type \"abc\" for a valid answer ",
6061
"INPUT2": "Number positive or negative -- input type=\"number\" -- Error on non-numeric characters ",
6162
"INPUT3": "Floating number range (integer excluded) -- between_num:x,y OR min_num:x|max_num:y ",

locales/validation/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"AREA1": "Area de texto: Alfanúmerica + Minimo(15) + Requerido",
5757
"ERRORS": "Errores",
5858
"CHANGE_LANGUAGE": "Cambiar idioma",
59+
"FORM_PREVALIDATED": "La forma es pre-validado",
5960
"INPUT1": "Validación Remota - Escriba \"abc\" para una respuesta válida ",
6061
"INPUT2": "Número positivo o negativo -- input type=\"number\" -- Error o caracteres no númericos ",
6162
"INPUT3": "Rango decimal (Los números enteros no son validos) -- between_num:x,y ó min_num:x|max_num:y ",

locales/validation/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"AREA1": "TextArea: Alphanumérique + Minimum(15) + Required",
5757
"ERRORS": "Erreurs",
5858
"CHANGE_LANGUAGE": "Changer de langue",
59+
"FORM_PREVALIDATED": "Formulaire est pré-validé",
5960
"INPUT1": "Validation à Distance - Taper \"abc\" pour une réponse valide ",
6061
"INPUT2": "Nombre positif ou négatif -- input type=\"number\" -- Erreur sur caractères non-numérique",
6162
"INPUT3": "Intervalle de Nombre Flottant (entier exclu) -- between_num:x,y OU min_num:x|max_num:y",

locales/validation/no.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"AREA1": "TextArea: Alfanumerisk + Minimum(15) + Påkrevd",
5757
"ERRORS": "Feil",
5858
"CHANGE_LANGUAGE": "Endre språk.",
59+
"FORM_PREVALIDATED": "Form er pre-godkjent",
5960
"INPUT1": "Ekstern Validering - Type \"abc\" for et gyldig svar ",
6061
"INPUT2": "Positivt eller negativt nummer -- input type=\"number\" -- Feil på ikke-numeriske tegn ",
6162
"INPUT3": "Flyttalssutvalg (heltall ekskludert) -- between_num:x,y eller min_num:x|max_num:y ",

0 commit comments

Comments
 (0)