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

Commit bd3dd6e

Browse files
committed
include a watch for UI Router
1 parent ffe2fa6 commit bd3dd6e

File tree

7 files changed

+50
-22
lines changed

7 files changed

+50
-22
lines changed

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.5.9",
3+
"version": "1.5.10",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [

dist/angular-validation.min.js

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

gulpfile.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var argv = require('yargs').argv,
22
gulp = require('gulp'),
33
gulpif = require('gulp-if'),
4+
protractor = require("gulp-angular-protractor"),
45
bump = require('gulp-bump'),
56
del = require('del'),
67
concat = require('gulp-concat'),
@@ -99,4 +100,17 @@ gulp.task('compress', ['clean'], function() {
99100
.pipe(concat('angular-validation.min.js'))
100101
.pipe(header(jsHeaderComment, { pkg : pkg, version: newVersion } ))
101102
.pipe(gulp.dest('dist'));
103+
});
104+
105+
gulp.task('test', function() {
106+
gulp.src(["./protractor/*_spec.js"])
107+
.pipe(protractor({
108+
configFile: "protractor/conf.js",
109+
args: ['--baseUrl', 'http://127.0.0.1'],
110+
'debug': false,
111+
'autoStartStopServer': true
112+
}))
113+
.on('error', function(e) {
114+
console.log(e);
115+
});
102116
});

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.9",
3+
"version": "1.5.10",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": "dist/angular-validation.min",
77
"dependencies": {},
88
"devDependencies": {
99
"del": "^1.2.1",
10+
"fs": "0.0.1-security",
1011
"gulp": "^3.9.0",
12+
"gulp-angular-protractor": "^0.2.0",
1113
"gulp-bump": "^0.3.1",
1214
"gulp-concat": "^2.6.0",
1315
"gulp-header": "^1.7.1",
@@ -16,6 +18,7 @@
1618
"gulp-replace-task": "^0.1.0",
1719
"gulp-strip-debug": "^1.1.0",
1820
"gulp-uglify": "^1.5.3",
21+
"protractor": "^4.0.11",
1922
"semver": "^4.3.6",
2023
"yargs": "^3.32.0"
2124
},

protractor/conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
capabilities: {
66
// browser to run test with
77
'browserName': 'chrome',
8+
'binary': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
89
'chromeOptions': {
910
// get rid of --ignore-certificate yellow warning
1011
args: ['--no-sandbox', 'test-type=browser', 'disable-extensions'],

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.5.9`
2+
`Version: 1.5.10`
33
### Forms Validation with Angular made easy!
44
##### (Concept comes from the amazing Laravel)
55

src/validation-common.js

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,10 @@ angular
2222

2323
// watch on route change, then reset some global variables, so that we don't carry over other controller/view validations
2424
$rootScope.$on("$routeChangeStart", function (event, next, current) {
25-
if (_globalOptions.resetGlobalOptionsOnRouteChange) {
26-
_globalOptions = {
27-
displayOnlyLastErrorMsg: false, // reset the option of displaying only the last error message
28-
errorMessageSeparator: ' ', // separator between each error messages (when multiple errors exist)
29-
hideErrorUnderInputs: false, // reset the option of hiding error under element
30-
preValidateFormElements: false, // reset the option of pre-validate all form elements, false by default
31-
preValidateValidationSummary: true, // reset the option of pre-validate all form elements, false by default
32-
isolatedScope: null, // reset used scope on route change
33-
scope: null, // reset used scope on route change
34-
validateOnEmpty: false, // reset the flag of Validate Always
35-
validRequireHowMany: "all", // how many Validators it needs to pass for the field to become valid, "all" by default
36-
resetGlobalOptionsOnRouteChange: true
37-
};
38-
_formElements = []; // array containing all form elements, valid or invalid
39-
_validationSummary = []; // array containing the list of invalid fields inside a validationSummary
40-
}
25+
resetGlobalOptions(_globalOptions.resetGlobalOptionsOnRouteChange);
26+
});
27+
$rootScope.$on("$stateChangeStart", function (event, next, current) {
28+
resetGlobalOptions(_globalOptions.resetGlobalOptionsOnRouteChange);
4129
});
4230

4331
// service constructor
@@ -970,6 +958,28 @@ angular
970958
return new Date(year, month - 1, day, hour, min, sec);
971959
}
972960

961+
/** Reset all the available Global Options of Angular-Validation
962+
* @param bool do a Reset?
963+
*/
964+
function resetGlobalOptions(doReset) {
965+
if (doReset) {
966+
_globalOptions = {
967+
displayOnlyLastErrorMsg: false, // reset the option of displaying only the last error message
968+
errorMessageSeparator: ' ', // separator between each error messages (when multiple errors exist)
969+
hideErrorUnderInputs: false, // reset the option of hiding error under element
970+
preValidateFormElements: false, // reset the option of pre-validate all form elements, false by default
971+
preValidateValidationSummary: true, // reset the option of pre-validate all form elements, false by default
972+
isolatedScope: null, // reset used scope on route change
973+
scope: null, // reset used scope on route change
974+
validateOnEmpty: false, // reset the flag of Validate Always
975+
validRequireHowMany: 'all', // how many Validators it needs to pass for the field to become valid, "all" by default
976+
resetGlobalOptionsOnRouteChange: true
977+
};
978+
_formElements = []; // array containing all form elements, valid or invalid
979+
_validationSummary = []; // array containing the list of invalid fields inside a validationSummary
980+
}
981+
}
982+
973983
/** From a date substring split it by a given separator and return a split array
974984
* @param string dateSubStr
975985
* @param string dateSeparator

0 commit comments

Comments
 (0)