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

Commit

Permalink
include a watch for UI Router
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Dec 14, 2016
1 parent ffe2fa6 commit bd3dd6e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 22 deletions.
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.5.9",
"version": "1.5.10",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": [
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-validation.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var argv = require('yargs').argv,
gulp = require('gulp'),
gulpif = require('gulp-if'),
protractor = require("gulp-angular-protractor"),
bump = require('gulp-bump'),
del = require('del'),
concat = require('gulp-concat'),
Expand Down Expand Up @@ -99,4 +100,17 @@ gulp.task('compress', ['clean'], function() {
.pipe(concat('angular-validation.min.js'))
.pipe(header(jsHeaderComment, { pkg : pkg, version: newVersion } ))
.pipe(gulp.dest('dist'));
});

gulp.task('test', function() {
gulp.src(["./protractor/*_spec.js"])
.pipe(protractor({
configFile: "protractor/conf.js",
args: ['--baseUrl', 'http://127.0.0.1'],
'debug': false,
'autoStartStopServer': true
}))
.on('error', function(e) {
console.log(e);
});
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "angular-validation-ghiscoding",
"version": "1.5.9",
"version": "1.5.10",
"author": "Ghislain B.",
"description": "Angular-Validation Directive and Service (ghiscoding)",
"main": "dist/angular-validation.min",
"dependencies": {},
"devDependencies": {
"del": "^1.2.1",
"fs": "0.0.1-security",
"gulp": "^3.9.0",
"gulp-angular-protractor": "^0.2.0",
"gulp-bump": "^0.3.1",
"gulp-concat": "^2.6.0",
"gulp-header": "^1.7.1",
Expand All @@ -16,6 +18,7 @@
"gulp-replace-task": "^0.1.0",
"gulp-strip-debug": "^1.1.0",
"gulp-uglify": "^1.5.3",
"protractor": "^4.0.11",
"semver": "^4.3.6",
"yargs": "^3.32.0"
},
Expand Down
1 change: 1 addition & 0 deletions protractor/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
capabilities: {
// browser to run test with
'browserName': 'chrome',
'binary': "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
'chromeOptions': {
// get rid of --ignore-certificate yellow warning
args: ['--no-sandbox', 'test-type=browser', 'disable-extensions'],
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Angular Validation (Directive / Service)
`Version: 1.5.9`
`Version: 1.5.10`
### Forms Validation with Angular made easy!
##### (Concept comes from the amazing Laravel)

Expand Down
42 changes: 26 additions & 16 deletions src/validation-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,10 @@ angular

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

// service constructor
Expand Down Expand Up @@ -970,6 +958,28 @@ angular
return new Date(year, month - 1, day, hour, min, sec);
}

/** Reset all the available Global Options of Angular-Validation
* @param bool do a Reset?
*/
function resetGlobalOptions(doReset) {
if (doReset) {
_globalOptions = {
displayOnlyLastErrorMsg: false, // reset the option of displaying only the last error message
errorMessageSeparator: ' ', // separator between each error messages (when multiple errors exist)
hideErrorUnderInputs: false, // reset the option of hiding error under element
preValidateFormElements: false, // reset the option of pre-validate all form elements, false by default
preValidateValidationSummary: true, // reset the option of pre-validate all form elements, false by default
isolatedScope: null, // reset used scope on route change
scope: null, // reset used scope on route change
validateOnEmpty: false, // reset the flag of Validate Always
validRequireHowMany: 'all', // how many Validators it needs to pass for the field to become valid, "all" by default
resetGlobalOptionsOnRouteChange: true
};
_formElements = []; // array containing all form elements, valid or invalid
_validationSummary = []; // array containing the list of invalid fields inside a validationSummary
}
}

/** From a date substring split it by a given separator and return a split array
* @param string dateSubStr
* @param string dateSeparator
Expand Down

0 comments on commit bd3dd6e

Please sign in to comment.