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

Commit

Permalink
Breaking Change rename ValidationService issue #107
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ghiscoding committed Feb 24, 2016
1 parent f68943e commit 3219b4d
Show file tree
Hide file tree
Showing 24 changed files with 114 additions and 106 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#################
## bower Package
#################
bower_components/

#################
## NPM Package
#################
Expand Down
13 changes: 8 additions & 5 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
full-tests
more-examples
protractor
templates
bower_components/
full-tests/
more-examples/
protractor/
templates/
.gitignore
app.js
app.js
gulpfile.js
index.html
20 changes: 10 additions & 10 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio

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

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

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

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

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

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

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

$scope.submitForm = function() {
if(new validationService().checkFormValidity($scope.form01)) {
if(new ValidationService().checkFormValidity($scope.form01)) {
alert('All good, proceed with submit...');
}
}
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": "angular-validation-ghiscoding",
"version": "1.4.22",
"version": "1.5.0",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": [
Expand Down
12 changes: 6 additions & 6 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions full-tests/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio

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

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

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

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

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

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

$scope.submitForm = function() {
if(new validationService().checkFormValidity($scope.form01)) {
if(new ValidationService().checkFormValidity($scope.form01)) {
alert('All good, proceed with submit...');
}
}
Expand Down
4 changes: 2 additions & 2 deletions more-examples/addon-3rdParty/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ myApp.config(['$compileProvider', function ($compileProvider) {
$translateProvider.preferredLanguage('en').fallbackLanguage('en');
}]);

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

vm.tags1 = [
{ id: 1, text: 'Tag1' },
Expand Down
8 changes: 4 additions & 4 deletions more-examples/angular-ui-calendar/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ myApp.config(['$compileProvider', function ($compileProvider) {
}]);

myApp.controller('Ctrl',
['$scope', '$translate', 'validationService', '$timeout',
function ($scope, $translate, validationService, $timeout) {
['$scope', '$translate', 'ValidationService', '$timeout',
function ($scope, $translate, ValidationService, $timeout) {
var vm = this;
vm.model = {};
vm.validationRequired = false;
Expand All @@ -37,8 +37,8 @@ function ($scope, $translate, validationService, $timeout) {
vm.isChangeDatePickerOpen = true;
};

var validation = new validationService({
controllerAs: vm,
var validation = new ValidationService({
controllerAs: vm,
preValidateFormElements: false
});

Expand Down
18 changes: 9 additions & 9 deletions more-examples/controllerAsWithRoute/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,27 @@ myApp.config(['$compileProvider', function ($compileProvider) {
}]);

myApp.controller('Ctrl', [
'validationService',
function (validationService) {
'ValidationService',
function (ValidationService) {
var vm = this;
vm.model = {};
var v1 = new validationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false });
var v1 = new ValidationService({ controllerAs: vm, resetGlobalOptionsOnRouteChange: false });
}]);

myApp.controller('FirstCtrl', [
'validationService',
function (validationService) {
'ValidationService',
function (ValidationService) {
var vm = this;
vm.model = {};
var v2 = new validationService({ controllerAs: vm });
var v2 = new ValidationService({ controllerAs: vm });
}
]);

myApp.controller('SecondCtrl', [
'validationService',
function (validationService) {
'ValidationService',
function (ValidationService) {
var vm = this;
vm.model = {};
var v3 = new validationService({ controllerAs: vm });
var v3 = new ValidationService({ controllerAs: vm });
}
]);
14 changes: 7 additions & 7 deletions more-examples/customRemote/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {

// --
// Directive
myApp.controller('CtrlDirective', ['$q', 'validationService', function ($q, validationService) {
myApp.controller('CtrlDirective', ['$q', 'ValidationService', function ($q, ValidationService) {
var vmd = this;
vmd.model = {};

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

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

// --
// Service
myApp.controller('CtrlService', ['$scope', '$q', 'validationService', function ($scope, $q, validationService) {
myApp.controller('CtrlService', ['$scope', '$q', 'ValidationService', function ($scope, $q, ValidationService) {
var vms = this;
vms.model = {};

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

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

vms.submitForm = function() {
if(new validationService().checkFormValidity(vms.form2)) {
if(new ValidationService().checkFormValidity(vms.form2)) {
alert('All good, proceed with submit...');
}
}
Expand Down
14 changes: 7 additions & 7 deletions more-examples/customValidation/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {

// --
// Directive
myApp.controller('CtrlDirective', ['validationService', function (validationService) {
myApp.controller('CtrlDirective', ['ValidationService', function (ValidationService) {
var vmd = this;
vmd.model = {};

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

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

// --
// Service
myApp.controller('CtrlService', ['$scope', 'validationService', function ($scope, validationService) {
myApp.controller('CtrlService', ['$scope', 'ValidationService', function ($scope, ValidationService) {
var vms = this;
vms.model = {};

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

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

vms.submitForm = function() {
if(new validationService().checkFormValidity(vms.form2)) {
if(new ValidationService().checkFormValidity(vms.form2)) {
alert('All good, proceed with submit...');
}
}
Expand Down
4 changes: 2 additions & 2 deletions more-examples/customValidationOnEmptyField/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ myApp.run(function ($rootScope) {
});

angular.module('emptyCustomValidation.controllers', []).
controller('myController', function($scope, validationService) {
controller('myController', function($scope, ValidationService) {
$scope.existingEmployees = [
{
firstName: 'John',
Expand All @@ -44,7 +44,7 @@ controller('myController', function($scope, validationService) {
];

$scope.submit = function() {
if (!new validationService().checkFormValidity($scope.inputForm)) {
if (!new ValidationService().checkFormValidity($scope.inputForm)) {
var msg = '';
$scope.inputForm.$validationSummary.forEach(function (validationItem) {
msg += validationItem.message + '\n';
Expand Down
4 changes: 2 additions & 2 deletions more-examples/dynamic-form/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ app.directive('formField',function() {
}
});

app.controller('MainCtrl', function($scope,validationService) {
app.controller('MainCtrl', function($scope,ValidationService) {
$scope.name = 'World';
$scope.items={};
$scope.items.item1 = {
Expand Down Expand Up @@ -65,7 +65,7 @@ app.controller('MainCtrl', function($scope,validationService) {
for(var key in $scope.items) {
var formName=$scope.items[key].formName;

if(new validationService().checkFormValidity($scope[formName])) {
if(new ValidationService().checkFormValidity($scope[formName])) {
$scope[formName].isValid = true;
}
else {
Expand Down
4 changes: 2 additions & 2 deletions more-examples/dynamic-modal-with-numeric-input/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ app.controller('ListController',['$scope', function($scope) {
$scope.items = [{"id": 1},{"id": 2}];
}]);

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

var myValidation = new validationService({ formName: 'itemsEdit' });
var myValidation = new ValidationService({ formName: 'itemsEdit' });

$scope.animationsEnabled = true;

Expand Down
6 changes: 3 additions & 3 deletions more-examples/interpolateValidation/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ myApp.config(['$compileProvider', function ($compileProvider) {
}]);

myApp.controller('Ctrl',
['$scope', '$translate', 'validationService',
function ($scope, $translate, validationService) {
['$scope', '$translate', 'ValidationService',
function ($scope, $translate, ValidationService) {
var vm = this;
vm.model = {};
vm.validationRequired = true;
var validation = new validationService({ controllerAs: vm, preValidateFormElements: true });
var validation = new ValidationService({ controllerAs: vm, preValidateFormElements: true });

vm.f1Validation = function () {
return vm.validationRequired ? 'required' : '';
Expand Down
6 changes: 3 additions & 3 deletions more-examples/ngIfShowHideDisabled/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ myApp.config(['$translateProvider', function ($translateProvider) {
$translateProvider.preferredLanguage('en').fallbackLanguage('en');
}]);

myApp.controller('Ctrl', ['$scope', 'validationService',
function($scope, validationService) {
myApp.controller('Ctrl', ['$scope', 'ValidationService',
function($scope, ValidationService) {

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

$scope.ModelData = {};
$scope.ModelData.IsShowNote = false;
Expand Down
6 changes: 3 additions & 3 deletions more-examples/ui-mask/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ myApp.config(['$compileProvider', function ($compileProvider) {
}]);

myApp.controller('Ctrl',
['$scope', '$translate', 'validationService', '$timeout',
function ($scope, $translate, validationService, $timeout) {
['$scope', '$translate', 'ValidationService', '$timeout',
function ($scope, $translate, ValidationService, $timeout) {
var vm = this;
vm.model = {};

function next(form) {
var vs = new validationService();
var vs = new ValidationService();
if (vs.checkFormValidity(form)) {
// proceed to another view
};
Expand Down
Loading

0 comments on commit 3219b4d

Please sign in to comment.