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

Commit 84976fc

Browse files
committed
Fixed a bug with ngDisabled not interpreted
- Fixed a bug with ngDisabled not being interpreted before observing it (ng-disabled="vm.type == 1" would give false result because it was not being interpreted), added Protractor Test for this behavior in 2Forms page. - Added `displayOnlyLastErrorMsg` in the list of Global Options. - Cleaned up a lot of code.
1 parent 94bc2d1 commit 84976fc

12 files changed

+347
-239
lines changed

app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
106106
// #3 .addValidator({ elmName: 'inputX', rules: 'myRules'})
107107
// the available object properties are the exact same set as the directive except that they are camelCase
108108
myValidation
109-
.setGlobalOptions({ debounce: 1500, scope: $scope, isolatedScope: $scope, preValidateFormElements: false })
109+
.setGlobalOptions({ debounce: 1500, scope: $scope, isolatedScope: $scope, preValidateFormElements: false, displayOnlyLastErrorMsg: false })
110110
.addValidator({ elmName: 'input2', debounce: 3000, rules: 'numeric_signed|required'})
111111
.addValidator('input3', 'float_signed|between_num:-0.6,99.5|required')
112112
.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

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

changelog.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ Angular-Validation change logs
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.
3030
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. 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.
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. 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.
32+
1.3.28 (2015-06-04) Fixed a bug with ngDisabled not being interpreted before observing it (ng-disabled="vm.type == 1" would give false result because it was not being interpreted), added Protractor Test for this behavior in 2Forms page. Added `displayOnlyLastErrorMsg` in the list of Global Options. Cleaned up a lot of code.

dist/angular-validation.min.js

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

package.json

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

protractor/mixed_validation_spec.js

+66-8
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
'Alphanumeric + Exactly(3) + Required -- debounce(3sec)',
2323
'Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01',
2424
'Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15',
25-
'TextArea: Alphanumeric + Minimum(15) + Required'
25+
'TextArea: Alphanumeric + Minimum(15) + Required',
26+
'Input20 - ngDisabled =>'
2627
];
2728
var errorMessages = [
2829
'Must be a positive or negative number. Field is required.',
@@ -71,17 +72,19 @@
7172
var types = ['Directive', 'Service'];
7273

7374
// variables used on 2Forms web page
74-
var formElement2FormsNames = ['input2', 'input3', 'select1', 'area1'];
75-
var formElement2FormsSummaryNames = ['First Name', 'Last Name', 'area1', 'select1'];
75+
var formElement2FormsNames = ['input2', 'input3', 'input4', 'select1', 'area1'];
76+
var formElement2FormsSummaryNames = ['First Name', 'Last Name', 'input4', 'area1', 'select1'];
7677
var errorMessages2Forms = [
7778
'May only contain letters, numbers and dashes. Must be at least 2 characters. Field is required.',
7879
'May only contain letters, numbers and dashes. Must be at least 2 characters. Field is required.',
7980
'Change language',
8081
'May only contain letters, numbers, dashes and spaces. Must be at least 15 characters. Field is required.'
8182
];
83+
var errorMessages2FormsExtra = 'Field is required.';
8284
var validInput2FormsTexts = [
8385
'John',
8486
'Doe',
87+
'abc',
8588
'en',
8689
'This is a great tool'
8790
];
@@ -303,8 +306,8 @@
303306
var inputName;
304307

305308
for (var i = 0, j = 0, ln = itemRows.length; i < ln; i++) {
306-
// since field after input13 is part of errorMessages and is empty string, we need to skip that one
307-
if (formElement2FormsNames[i] === 'input13') {
309+
// since field after input4 is part of errorMessages and is empty string, we need to skip that one
310+
if (formElement2FormsNames[i] === 'input4') {
308311
j++;
309312
}
310313
expect(itemRows.get(i).getText()).toEqual(formElement2FormsSummaryNames[i] + ': ' + errorMessages2Forms[j++]);
@@ -314,10 +317,11 @@
314317

315318
it('Should enter valid text and make error go away', function () {
316319
for (var i = 0, ln = formElement2FormsNames.length; i < ln; i++) {
317-
// some fields are not required or disabled so no error will show up, continue to next ones
318-
if (formElement2FormsNames[i] === 'input12' || formElement2FormsNames[i] === 'input14') {
320+
// since field after input4 is part of errorMessages and is empty string, we need to skip that one
321+
if (formElement2FormsNames[i] === 'input4') {
319322
continue;
320323
}
324+
321325
var elmInput = $('[name=' + formElement2FormsNames[i] + ']');
322326
elmInput.click();
323327
elmInput.sendKeys(validInput2FormsTexts[i]);
@@ -332,7 +336,61 @@
332336
}
333337
});
334338

335-
it('Should check that both submit button are now enabled', function() {
339+
it('Should check that both submit buttons are now enabled', function() {
340+
var elmSubmit1 = $('[name=save_btn1]');
341+
expect(elmSubmit1.isEnabled()).toBe(true);
342+
343+
var elmSubmit2 = $('[name=save_btn2]');
344+
expect(elmSubmit2.isEnabled()).toBe(true);
345+
});
346+
347+
it('Should make input4 editable & error should show on input4', function() {
348+
// click on the radio button OFF, that will make the input editable
349+
element(by.id('radioDisableInput4_off')).click();
350+
351+
// error should appear
352+
var elmError = $('.validation-input4');
353+
expect(elmError.getText()).toEqual(errorMessages2FormsExtra);
354+
355+
// Save button should become disable
356+
var elmSubmit1 = $('[name=save_btn1]');
357+
expect(elmSubmit1.isEnabled()).toBe(false);
358+
});
359+
360+
it('Should show input4 error in ValidationSummary', function () {
361+
var btnShowSummary = $('button[name=btn_showValidation]');
362+
btnShowSummary.click();
363+
browser.waitForAngular();
364+
365+
// showValidation checkbox should false at first but true after
366+
var elmCheckboxShowSummary = element(by.model('displayValidationSummary'));
367+
expect(elmCheckboxShowSummary.isSelected()).toBeTruthy();
368+
369+
// scroll back to top
370+
browser.executeScript('window.scrollTo(0,0);').then(function () {
371+
var itemRows = element.all(by.binding('message'));
372+
var inputName;
373+
374+
for (var i = 0, j = 0, ln = itemRows.length; i < ln; i++) {
375+
expect(itemRows.get(i).getText()).toEqual('input4: Field is required.');
376+
}
377+
});
378+
});
379+
380+
it('Should disable input4, error go away from input & validation summary', function() {
381+
// click on the radio button OFF, that will make the input editable
382+
element(by.id('radioDisableInput4_on')).click();
383+
384+
// error should appear
385+
var elmError = $('.validation-input4');
386+
expect(elmError.getText()).toEqual('');
387+
388+
// validation summary should become empty
389+
var itemRows = element.all(by.binding('message'));
390+
expect(itemRows.count()).toBe(0);
391+
});
392+
393+
it('Should check that both submit buttons are now enabled', function() {
336394
var elmSubmit1 = $('[name=save_btn1]');
337395
expect(elmSubmit1.isEnabled()).toBe(true);
338396

readme.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.3.27`
2+
`Version: 1.3.28`
33
### Form validation after user inactivity of default 1sec. (customizable timeout)
44

55
Forms Validation with Angular made easy! Angular-Validation is an angular directive/service with locales (languages) with a very simple approach of defining your `validation=""` directly within your element to validate (input, textarea, etc) and...that's it!!! The directive/service will take care of the rest!
@@ -24,7 +24,7 @@ If you do use Angular-Validation, please click on the **Star** and add it as a f
2424
[Plunker](http://plnkr.co/jADq7H)
2525

2626
## Tested with Protractor
27-
Angular-validation now has a full set of End-to-End tests with Protractor, there is over 1300+ assertions, it starts by testing the original live demo page and then goes on with a complete test suite of All Validators in both the Angular-Validation Directive and Service.
27+
Angular-validation now has a full set of End-to-End tests with Protractor, there is over 1400+ assertions, it starts by testing the original live demo page and then goes on with a complete test suite of All Validators in both the Angular-Validation Directive and Service.
2828

2929
<a name="whyuseit"></a>
3030
Why use angular-validation?
@@ -81,6 +81,9 @@ All the documentation has been moved to the Wiki section, see the [github wiki](
8181
* [Remove a Validator](https://github.com/ghiscoding/angular-validation/wiki/Remove-Validator-from-Element)
8282
* [Submit and Validation](https://github.com/ghiscoding/angular-validation/wiki/Form-Submit-and-Validation)
8383
* [Validation Summary](https://github.com/ghiscoding/angular-validation/wiki/Validation-Summary)
84+
* Properties & Options
85+
* [Inputs (all local options)](https://github.com/ghiscoding/angular-validation/wiki/Inputs-(local-options))
86+
* [Global Options](https://github.com/ghiscoding/angular-validation/wiki/Global-Options)
8487
* Validators
8588
* [Available Validator Rules](https://github.com/ghiscoding/angular-validation/wiki/Available-Validators-(rules))
8689
* [Regular Expression](https://github.com/ghiscoding/angular-validation/wiki/Regular-Expressions-(Regex))

0 commit comments

Comments
 (0)