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

Commit 3219b4d

Browse files
committed
Breaking Change rename ValidationService issue #107
- new 1.5.x branch has a breaking change, which is the fix of the uppercase on ValidationService object (instead of validationService which was wrong has mentioned in issue #107). - added angular-validation-ghiscoding to NPM and fixed the .npmignore
1 parent f68943e commit 3219b4d

File tree

24 files changed

+114
-106
lines changed

24 files changed

+114
-106
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#################
2+
## bower Package
3+
#################
4+
bower_components/
5+
16
#################
27
## NPM Package
38
#################

.npmignore

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
full-tests
2-
more-examples
3-
protractor
4-
templates
1+
bower_components/
2+
full-tests/
3+
more-examples/
4+
protractor/
5+
templates/
56
.gitignore
6-
app.js
7+
app.js
8+
gulpfile.js
9+
index.html

app.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio
3838

3939
// -- Controller to use Angular-Validation Directive
4040
// -----------------------------------------------
41-
myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService', function ($q, $scope, validationService) {
41+
myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'ValidationService', function ($q, $scope, ValidationService) {
4242
// you can change default debounce globally
4343
$scope.$validationOptions = { debounce: 1500, preValidateFormElements: false };
4444

@@ -49,13 +49,13 @@ myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService'
4949
// remove a single element ($scope.form1, string)
5050
// OR you can also remove multiple elements through an array type .removeValidator($scope.form1, ['input2','input3'])
5151
$scope.removeInputValidator = function ( elmName ) {
52-
new validationService().removeValidator($scope.form1, elmName);
52+
new ValidationService().removeValidator($scope.form1, elmName);
5353
};
5454
$scope.resetForm = function() {
55-
new validationService().resetForm($scope.form1);
55+
new ValidationService().resetForm($scope.form1);
5656
};
5757
$scope.submitForm = function() {
58-
if(new validationService().checkFormValidity($scope.form1)) {
58+
if(new ValidationService().checkFormValidity($scope.form1)) {
5959
alert('All good, proceed with submit...');
6060
}
6161
}
@@ -83,11 +83,11 @@ myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService'
8383
// -- Controller to use Angular-Validation Directive with 2 forms
8484
// on this page we will pre-validate the form and show all errors on page load
8585
// ---------------------------------------------------------------
86-
myApp.controller('Ctrl2forms', ['validationService', function (validationService) {
86+
myApp.controller('Ctrl2forms', ['ValidationService', function (ValidationService) {
8787
var vm = this; // use the ControllerAs alias syntax
8888

8989
// set the global options BEFORE any function declarations, we will prevalidate current form
90-
var myValidationService = new validationService({ controllerAs: vm, debounce: 500, preValidateFormElements: true });
90+
var myValidationService = new ValidationService({ controllerAs: vm, debounce: 500, preValidateFormElements: true });
9191

9292
vm.submitForm = function() {
9393
if(myValidationService.checkFormValidity(vm.form01)) {
@@ -106,9 +106,9 @@ myApp.controller('Ctrl2forms', ['validationService', function (validationService
106106
// -----------------------------------------------
107107

108108
// exact same testing form used except that all validators are programmatically added inside controller via Angular-Validation Service
109-
myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'validationService', function ($q, $scope, $translate, validationService) {
109+
myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'ValidationService', function ($q, $scope, $translate, ValidationService) {
110110
// start by creating the service
111-
var myValidation = new validationService();
111+
var myValidation = new ValidationService();
112112

113113
// you can create indepent call to the validation service
114114
// also below the multiple properties available
@@ -183,7 +183,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
183183

184184
// -- Controller to use Angular-Validation with Directive and ngRepeat
185185
// ---------------------------------------------------------------
186-
myApp.controller('CtrlNgRepeat', ['$scope', 'validationService', function ($scope, validationService) {
186+
myApp.controller('CtrlNgRepeat', ['$scope', 'ValidationService', function ($scope, ValidationService) {
187187
// Form data
188188
$scope.people = [
189189
{ name: 'John', age: 20 },
@@ -192,7 +192,7 @@ myApp.controller('CtrlNgRepeat', ['$scope', 'validationService', function ($scop
192192
];
193193

194194
$scope.submitForm = function() {
195-
if(new validationService().checkFormValidity($scope.form01)) {
195+
if(new ValidationService().checkFormValidity($scope.form01)) {
196196
alert('All good, proceed with submit...');
197197
}
198198
}

bower.json

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

dist/angular-validation.min.js

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

full-tests/app.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio
3838

3939
// -- Controller to use Angular-Validation with Directive
4040
// -------------------------------------------------------
41-
myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validationService', function ($scope, $translate, validationService) {
41+
myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'ValidationService', function ($scope, $translate, ValidationService) {
4242
$scope.$validationOptions = { debounce: 50 }; // set the debounce globally with very small time for faster Protactor sendKeys()
4343

4444
$scope.switchLanguage = function (key) {
@@ -49,7 +49,7 @@ myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validation
4949
$scope.validations = explodeAndFlattenValidatorArray(validatorDataset);
5050

5151
$scope.submitForm = function() {
52-
if(new validationService().checkFormValidity($scope.form01)) {
52+
if(new ValidationService().checkFormValidity($scope.form01)) {
5353
alert('All good, proceed with submit...');
5454
}
5555
}
@@ -60,12 +60,12 @@ myApp.controller('CtrlValidationDirective', ['$scope', '$translate', 'validation
6060

6161
// -- Controller to use Angular-Validation with Service
6262
// -------------------------------------------------------
63-
myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationService', function ($scope, $translate, validationService) {
63+
myApp.controller('CtrlValidationService', ['$scope', '$translate', 'ValidationService', function ($scope, $translate, ValidationService) {
6464
var validatorDataset = loadData();
6565
$scope.validations = explodeAndFlattenValidatorArray(validatorDataset);
6666

6767
// start by creating the service
68-
var myValidation = new validationService();
68+
var myValidation = new ValidationService();
6969
myValidation.setGlobalOptions({ debounce: 50, scope: $scope })
7070

7171
for(var i = 0, ln = $scope.validations.length; i < ln; i++) {
@@ -80,7 +80,7 @@ myApp.controller('CtrlValidationService', ['$scope', '$translate', 'validationSe
8080
};
8181

8282
$scope.submitForm = function() {
83-
if(new validationService().checkFormValidity($scope.form01)) {
83+
if(new ValidationService().checkFormValidity($scope.form01)) {
8484
alert('All good, proceed with submit...');
8585
}
8686
}

more-examples/addon-3rdParty/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1515
$translateProvider.preferredLanguage('en').fallbackLanguage('en');
1616
}]);
1717

18-
myApp.controller('Ctrl', ['validationService', function (validationService) {
18+
myApp.controller('Ctrl', ['ValidationService', function (ValidationService) {
1919
var vm = this;
20-
var myValidation = new validationService({ controllerAs: vm, formName: 'vm.test', preValidateFormElements: false });
20+
var myValidation = new ValidationService({ controllerAs: vm, formName: 'vm.test', preValidateFormElements: false });
2121

2222
vm.tags1 = [
2323
{ id: 1, text: 'Tag1' },

more-examples/angular-ui-calendar/app.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1515
}]);
1616

1717
myApp.controller('Ctrl',
18-
['$scope', '$translate', 'validationService', '$timeout',
19-
function ($scope, $translate, validationService, $timeout) {
18+
['$scope', '$translate', 'ValidationService', '$timeout',
19+
function ($scope, $translate, ValidationService, $timeout) {
2020
var vm = this;
2121
vm.model = {};
2222
vm.validationRequired = false;
@@ -37,8 +37,8 @@ function ($scope, $translate, validationService, $timeout) {
3737
vm.isChangeDatePickerOpen = true;
3838
};
3939

40-
var validation = new validationService({
41-
controllerAs: vm,
40+
var validation = new ValidationService({
41+
controllerAs: vm,
4242
preValidateFormElements: false
4343
});
4444

more-examples/controllerAsWithRoute/app.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,27 @@ myApp.config(['$compileProvider', function ($compileProvider) {
4545
}]);
4646

4747
myApp.controller('Ctrl', [
48-
'validationService',
49-
function (validationService) {
48+
'ValidationService',
49+
function (ValidationService) {
5050
var vm = this;
5151
vm.model = {};
52-
var v1 = new validationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false });
52+
var v1 = new ValidationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false });
5353
}]);
5454

5555
myApp.controller('FirstCtrl', [
56-
'validationService',
57-
function (validationService) {
56+
'ValidationService',
57+
function (ValidationService) {
5858
var vm = this;
5959
vm.model = {};
60-
var v2 = new validationService({ controllerAs: vm });
60+
var v2 = new ValidationService({ controllerAs: vm });
6161
}
6262
]);
6363

6464
myApp.controller('SecondCtrl', [
65-
'validationService',
66-
function (validationService) {
65+
'ValidationService',
66+
function (ValidationService) {
6767
var vm = this;
6868
vm.model = {};
69-
var v3 = new validationService({ controllerAs: vm });
69+
var v3 = new ValidationService({ controllerAs: vm });
7070
}
7171
]);

more-examples/customRemote/app.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1818

1919
// --
2020
// Directive
21-
myApp.controller('CtrlDirective', ['$q', 'validationService', function ($q, validationService) {
21+
myApp.controller('CtrlDirective', ['$q', 'ValidationService', function ($q, ValidationService) {
2222
var vmd = this;
2323
vmd.model = {};
2424

25-
// use the validationService only to declare the controllerAs syntax
26-
var vs = new validationService({ controllerAs: vmd, debounce: 500 });
25+
// use the ValidationService only to declare the controllerAs syntax
26+
var vs = new ValidationService({ controllerAs: vmd, debounce: 500 });
2727

2828
vmd.myRemoteValidation1 = function() {
2929
var deferred = $q.defer();
@@ -54,12 +54,12 @@ myApp.controller('CtrlDirective', ['$q', 'validationService', function ($q, vali
5454

5555
// --
5656
// Service
57-
myApp.controller('CtrlService', ['$scope', '$q', 'validationService', function ($scope, $q, validationService) {
57+
myApp.controller('CtrlService', ['$scope', '$q', 'ValidationService', function ($scope, $q, ValidationService) {
5858
var vms = this;
5959
vms.model = {};
6060

61-
// use the validationService only to declare the controllerAs syntax
62-
var vs = new validationService({ controllerAs: vms, debounce: 500 });
61+
// use the ValidationService only to declare the controllerAs syntax
62+
var vs = new ValidationService({ controllerAs: vms, debounce: 500 });
6363

6464
vs.setGlobalOptions({ scope: $scope })
6565
.addValidator('input3', 'alpha|min_len:2|remote:vms.myRemoteValidation3():alt=Alternate error message.|required')
@@ -86,7 +86,7 @@ myApp.controller('CtrlService', ['$scope', '$q', 'validationService', function (
8686
}
8787

8888
vms.submitForm = function() {
89-
if(new validationService().checkFormValidity(vms.form2)) {
89+
if(new ValidationService().checkFormValidity(vms.form2)) {
9090
alert('All good, proceed with submit...');
9191
}
9292
}

more-examples/customValidation/app.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1818

1919
// --
2020
// Directive
21-
myApp.controller('CtrlDirective', ['validationService', function (validationService) {
21+
myApp.controller('CtrlDirective', ['ValidationService', function (ValidationService) {
2222
var vmd = this;
2323
vmd.model = {};
2424

25-
// use the validationService only to declare the controllerAs syntax
26-
var vs = new validationService({ controllerAs: vmd });
25+
// use the ValidationService only to declare the controllerAs syntax
26+
var vs = new ValidationService({ controllerAs: vmd });
2727

2828
vmd.myCustomValidation1 = function() {
2929
// you can return a boolean for isValid or an objec (see the next function)
@@ -50,12 +50,12 @@ myApp.controller('CtrlDirective', ['validationService', function (validationServ
5050

5151
// --
5252
// Service
53-
myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope, validationService) {
53+
myApp.controller('CtrlService', ['$scope', 'ValidationService', function ($scope, ValidationService) {
5454
var vms = this;
5555
vms.model = {};
5656

57-
// use the validationService only to declare the controllerAs syntax
58-
var vs = new validationService({ controllerAs: vms });
57+
// use the ValidationService only to declare the controllerAs syntax
58+
var vs = new ValidationService({ controllerAs: vms });
5959

6060
vs.setGlobalOptions({ scope: $scope })
6161
.addValidator('input3', 'alpha|min_len:2|custom:vms.myCustomValidation3:alt=Alternate error message.|required')
@@ -80,7 +80,7 @@ myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope
8080
}
8181

8282
vms.submitForm = function() {
83-
if(new validationService().checkFormValidity(vms.form2)) {
83+
if(new ValidationService().checkFormValidity(vms.form2)) {
8484
alert('All good, proceed with submit...');
8585
}
8686
}

more-examples/customValidationOnEmptyField/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ myApp.run(function ($rootScope) {
2323
});
2424

2525
angular.module('emptyCustomValidation.controllers', []).
26-
controller('myController', function($scope, validationService) {
26+
controller('myController', function($scope, ValidationService) {
2727
$scope.existingEmployees = [
2828
{
2929
firstName: 'John',
@@ -44,7 +44,7 @@ controller('myController', function($scope, validationService) {
4444
];
4545

4646
$scope.submit = function() {
47-
if (!new validationService().checkFormValidity($scope.inputForm)) {
47+
if (!new ValidationService().checkFormValidity($scope.inputForm)) {
4848
var msg = '';
4949
$scope.inputForm.$validationSummary.forEach(function (validationItem) {
5050
msg += validationItem.message + '\n';

more-examples/dynamic-form/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ app.directive('formField',function() {
2222
}
2323
});
2424

25-
app.controller('MainCtrl', function($scope,validationService) {
25+
app.controller('MainCtrl', function($scope,ValidationService) {
2626
$scope.name = 'World';
2727
$scope.items={};
2828
$scope.items.item1 = {
@@ -65,7 +65,7 @@ app.controller('MainCtrl', function($scope,validationService) {
6565
for(var key in $scope.items) {
6666
var formName=$scope.items[key].formName;
6767

68-
if(new validationService().checkFormValidity($scope[formName])) {
68+
if(new ValidationService().checkFormValidity($scope[formName])) {
6969
$scope[formName].isValid = true;
7070
}
7171
else {

more-examples/dynamic-modal-with-numeric-input/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ app.controller('ListController',['$scope', function($scope) {
3434
$scope.items = [{"id": 1},{"id": 2}];
3535
}]);
3636

37-
app.controller('ModalController', ['$scope', '$modal', 'validationService', function ($scope, $modal, validationService) {
37+
app.controller('ModalController', ['$scope', '$modal', 'ValidationService', function ($scope, $modal, ValidationService) {
3838
"use strict";
3939

40-
var myValidation = new validationService({ formName: 'itemsEdit' });
40+
var myValidation = new ValidationService({ formName: 'itemsEdit' });
4141

4242
$scope.animationsEnabled = true;
4343

more-examples/interpolateValidation/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1515
}]);
1616

1717
myApp.controller('Ctrl',
18-
['$scope', '$translate', 'validationService',
19-
function ($scope, $translate, validationService) {
18+
['$scope', '$translate', 'ValidationService',
19+
function ($scope, $translate, ValidationService) {
2020
var vm = this;
2121
vm.model = {};
2222
vm.validationRequired = true;
23-
var validation = new validationService({ controllerAs: vm, preValidateFormElements: true });
23+
var validation = new ValidationService({ controllerAs: vm, preValidateFormElements: true });
2424

2525
vm.f1Validation = function () {
2626
return vm.validationRequired ? 'required' : '';

more-examples/ngIfShowHideDisabled/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ myApp.config(['$translateProvider', function ($translateProvider) {
1313
$translateProvider.preferredLanguage('en').fallbackLanguage('en');
1414
}]);
1515

16-
myApp.controller('Ctrl', ['$scope', 'validationService',
17-
function($scope, validationService) {
16+
myApp.controller('Ctrl', ['$scope', 'ValidationService',
17+
function($scope, ValidationService) {
1818

19-
var validate = new validationService({ debounce: 100, isolatedScope: $scope});
19+
var validate = new ValidationService({ debounce: 100, isolatedScope: $scope});
2020

2121
$scope.ModelData = {};
2222
$scope.ModelData.IsShowNote = false;

more-examples/ui-mask/app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ myApp.config(['$compileProvider', function ($compileProvider) {
1515
}]);
1616

1717
myApp.controller('Ctrl',
18-
['$scope', '$translate', 'validationService', '$timeout',
19-
function ($scope, $translate, validationService, $timeout) {
18+
['$scope', '$translate', 'ValidationService', '$timeout',
19+
function ($scope, $translate, ValidationService, $timeout) {
2020
var vm = this;
2121
vm.model = {};
2222

2323
function next(form) {
24-
var vs = new validationService();
24+
var vs = new ValidationService();
2525
if (vs.checkFormValidity(form)) {
2626
// proceed to another view
2727
};

0 commit comments

Comments
 (0)