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

Commit ba2ba9a

Browse files
committed
If translation isn't working, throw an error
1 parent 72f62bf commit ba2ba9a

19 files changed

+55
-10
lines changed

bower.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-validation-ghiscoding",
3-
"version": "1.5.4",
3+
"version": "1.5.5",
44
"author": "Ghislain B.",
55
"description": "Angular-Validation Directive and Service (ghiscoding)",
66
"main": [
@@ -47,4 +47,4 @@
4747
"devDependencies": {
4848
"angular-route": ">= 1.2.0"
4949
}
50-
}
50+
}

dist/angular-validation.min.js

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

more-examples/customRemote/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ myApp.controller('CtrlService', ['$scope', '$q', 'ValidationService', function (
6262
var vs = new ValidationService({ controllerAs: vms, debounce: 500 });
6363

6464
vs.setGlobalOptions({ scope: $scope })
65-
.addValidator('input3', 'alpha|min_len:2|remote:vms.myRemoteValidation3():alt=Alternate error message.|required')
65+
.addValidator('input3', 'alpha|min_len:2|remote:vms.myRemoteValidation3:alt=Alternate error message.|required')
6666
.addValidator('input4', 'alpha|min_len:2|remote:vms.myRemoteValidation4()|required');
6767

6868
vms.myRemoteValidation3 = function() {
6969
var deferred = $q.defer();
7070
setTimeout(function() {
7171
var isValid = (vms.model.input3 === "abc") ? true : false;
7272
deferred.resolve({ isValid: isValid, message: 'Returned error from promise.'});
73-
}, 500);
73+
}, 100);
7474

7575
return deferred.promise;
7676
}

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

protractor/angularUI_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
it('Should enter valid date expect no errors on input and validation summary', function () {
2121
var elmInput = $('[name=dateOfChange]');
2222
elmInput.sendKeys(validDate);
23+
element(by.css('body')).click();
2324
elmInput.sendKeys(protractor.Key.TAB);
2425

2526
// validation summary should become empty
@@ -30,6 +31,7 @@
3031
it('Should enter outside of range date and show dateOfChange error on input and ValidationSummary', function () {
3132
var elmInput = $('[name=dateOfChange]');
3233
elmInput.sendKeys(invalidOverDate);
34+
element(by.css('body')).click();
3335
elmInput.sendKeys(protractor.Key.TAB);
3436

3537
var itemRows = element.all(by.binding('message'));
@@ -43,6 +45,7 @@
4345
it('Should enter wrong date format and show dateOfChange error on input and ValidationSummary', function () {
4446
var elmInput = $('[name=dateOfChange]');
4547
elmInput.sendKeys(invalidTypoDate);
48+
element(by.css('body')).click();
4649
elmInput.sendKeys(protractor.Key.TAB);
4750

4851
var itemRows = element.all(by.binding('message'));

protractor/badInput_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Angular-Validation badInput Tests:', function () {
4545
it('Should display same invalid character error message even after a Tab', function() {
4646
// make input3 invalid, remove text
4747
var elmInput2 = $('[name=input2]');
48+
element(by.css('body')).click();
4849
elmInput2.sendKeys(protractor.Key.TAB);
4950

5051
// error should appear on input2
@@ -95,6 +96,7 @@ describe('Angular-Validation badInput Tests:', function () {
9596
var elmInput2 = $('[name=input2]');
9697
elmInput2.click();
9798
clearInput(elmInput2, 5);
99+
element(by.css('body')).click();
98100
elmInput2.sendKeys(protractor.Key.TAB);
99101

100102
// error should appear on input2

protractor/callback_spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('Angular-Validation callback Validation Tests:', function () {
4545
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
4646
var elmInput = $('[name=' + formElementNames[i] + ']');
4747
elmInput.click();
48+
element(by.css('body')).click();
4849
elmInput.sendKeys(protractor.Key.TAB);
4950

5051
var elmError = $('.validation-' + formElementNames[i]);

protractor/conf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
'browserName': 'chrome',
88
'chromeOptions': {
99
// get rid of --ignore-certificate yellow warning
10-
args: ['--no-sandbox', 'test-type=browser'],
10+
args: ['--no-sandbox', 'test-type=browser', 'disable-extensions'],
1111
// set download path and avoid prompting for download even though
1212
// even though this is already the default Chrome but for completeness
1313
prefs: {

protractor/controllerAsWithRoute_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
it('Should enter valid data and show 0 error on Top Form Valdation Summary', function () {
2727
var elmInput = $('[name=f1]');
2828
elmInput.sendKeys('abc');
29+
element(by.css('body')).click();
2930
elmInput.sendKeys(protractor.Key.TAB);
3031

3132
// validation summary should become empty
@@ -36,6 +37,7 @@
3637
it('Should enter valid data and show 0 error on bottom Form Valdation Summary in ngView (First Route)', function () {
3738
var elmInput = $('[name=firstField]');
3839
elmInput.sendKeys('abc');
40+
element(by.css('body')).click();
3941
elmInput.sendKeys(protractor.Key.TAB);
4042

4143
// validation summary should become empty
@@ -63,6 +65,7 @@
6365
it('Should enter valid data and show 0 error on bottom Form Valdation Summary in ngView (First Route)', function () {
6466
var elmInput = $('[name=secondField]');
6567
elmInput.sendKeys('abc');
68+
element(by.css('body')).click();
6669
elmInput.sendKeys(protractor.Key.TAB);
6770

6871
// validation summary should become empty

protractor/custom_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
5151
var elmInput = $('[name=' + formElementNames[i] + ']');
5252
elmInput.click();
53+
element(by.css('body')).click();
5354
elmInput.sendKeys(protractor.Key.TAB);
5455

5556
var elmError = $('.validation-' + formElementNames[i]);
@@ -74,6 +75,7 @@
7475
elmInput.click();
7576
clearInput(elmInput);
7677
elmInput.sendKeys(validInputTexts[i]);
78+
element(by.css('body')).click();
7779
elmInput.sendKeys(protractor.Key.TAB);
7880

7981
var elmError = $('.validation-' + formElementNames[i]);
@@ -114,6 +116,7 @@
114116
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
115117
var elmInput = $('[name=' + formElementNames[i] + ']');
116118
elmInput.click();
119+
element(by.css('body')).click();
117120
elmInput.sendKeys(protractor.Key.TAB);
118121

119122
var elmError = $('.validation-' + formElementNames[i]);

protractor/dynamic_spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828
it('Should enter valid data in Form1 and expect valid Form1 but invalid Form2', function () {
2929
var elmFirstName = $('[name=firstName]');
3030
elmFirstName.sendKeys('abc');
31+
element(by.css('body')).click();
3132
elmFirstName.sendKeys(protractor.Key.TAB);
3233

3334
var elmLastName = $('[name=lastName]');
3435
elmLastName.sendKeys('def');
36+
element(by.css('body')).click();
3537
elmLastName.sendKeys(protractor.Key.TAB);
3638

3739
var validateBtn = $('[name=validateForms]');
@@ -54,10 +56,12 @@
5456
it('Should enter valid data in Form2 and expect both Forms to be valid', function () {
5557
var elmEmail = $('[name=email]');
5658
elmEmail.sendKeys('abc');
59+
element(by.css('body')).click();
5760
elmEmail.sendKeys(protractor.Key.TAB);
5861

5962
var elmPhone = $('[name=phoneNo]');
6063
elmPhone.sendKeys('def');
64+
element(by.css('body')).click();
6165
elmPhone.sendKeys(protractor.Key.TAB);
6266

6367
var validateBtn = $('[name=validateForms]');

protractor/full_tests_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
for (var i = 0, ln = validations.length; i < ln; i++) {
5050
var elmInput = $('[name=input' + i + ']');
5151
elmInput.click();
52+
element(by.css('body')).click();
5253
elmInput.sendKeys(protractor.Key.TAB);
5354
//$('[for=input' + i + ']').click();
5455

@@ -73,6 +74,7 @@
7374
(function(elmInput, data, i) {
7475
elmInput.clear().then(function() {
7576
elmInput.sendKeys(data);
77+
element(by.css('body')).click();
7678
elmInput.sendKeys(protractor.Key.TAB);
7779
//$('[for=input' + i + ']').click();
7880
var elmError = $('.validation-input' + i);
@@ -100,6 +102,7 @@
100102
(function(elmInput, data, i) {
101103
elmInput.clear().then(function() {
102104
elmInput.sendKeys(data);
105+
element(by.css('body')).click();
103106
elmInput.sendKeys(protractor.Key.TAB);
104107
//$('[for=input' + i + ']').click();
105108
var elmError = $('.validation-input' + i);

protractor/interpolate_spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
it('Should enter valid data and show 0 error on bottom Form in ngView (First Route)', function () {
3333
var elmInput = $('[name=if1]');
3434
elmInput.sendKeys('abc');
35+
element(by.css('body')).click();
3536
elmInput.sendKeys(protractor.Key.TAB);
3637

3738
// validation summary should become empty

protractor/mixed_validation_spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
it('Should click, blur on Remote input and error message should display', function () {
131131
var elmInput = $('[name=input1]');
132132
elmInput.click();
133+
element(by.css('body')).click();
133134
elmInput.sendKeys(protractor.Key.TAB);
134135
//$('[for=input1]').click();
135136
browser.waitForAngular();
@@ -143,6 +144,7 @@
143144
var elmInput = $('[name=input1]');
144145
elmInput.click();
145146
elmInput.sendKeys('ab');
147+
element(by.css('body')).click();
146148
elmInput.sendKeys(protractor.Key.TAB);
147149
//$('[for=input1]').click();
148150
browser.sleep(1100); // sleep because of our data sample having a delay of 1sec internally, we use 1.5sec on this side to be sure
@@ -155,6 +157,7 @@
155157
var elmInput = $('[name=input1]');
156158
elmInput.clear().then(function() {
157159
elmInput.sendKeys('abc');
160+
element(by.css('body')).click();
158161
elmInput.sendKeys(protractor.Key.TAB);
159162
//$('[for=input1]').click();
160163
browser.sleep(1100); // sleep because of our data sample having a delay of 1sec internally, we use 1.5sec on this side to be sure
@@ -172,12 +175,14 @@
172175
}
173176
var elmInput = $('[name=' + formElementNames[i] + ']');
174177
elmInput.click();
178+
element(by.css('body')).click();
175179
elmInput.sendKeys(protractor.Key.TAB);
176180
//$('[for=' + formElementNames[i] + ']').click(); // click on label to blur away
177181

178182
if (formElementNames[i] === 'select1') {
179183
element(by.cssContainingText('option', 'en')).click(); // click on good option first
180184
element(by.cssContainingText('option', '...')).click(); // then click on option[0], the one containing '...'
185+
element(by.css('body')).click();
181186
elmInput.sendKeys(protractor.Key.TAB);
182187

183188
var elmError = $('.validation-select1');
@@ -191,6 +196,7 @@
191196
});
192197

193198
it('Should enter valid text and make error go away', function () {
199+
browser.sleep(2000);
194200
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
195201
// some fields are not required or disabled so no error will show up, continue to next ones
196202
if (formElementNames[i] === 'input12' || formElementNames[i] === 'input14') {
@@ -200,11 +206,13 @@
200206
elmInput.click();
201207
elmInput.sendKeys(validInputTexts[i]);
202208
elmInput.sendKeys(protractor.Key.TAB);
209+
element(by.css('body')).click();
203210
//$('[for=' + formElementNames[i] + ']').click(); // click on label to blur away
204211

205212
if (formElementNames[i] === 'select1') {
206213
element(by.cssContainingText('option', validInputTexts[i])).click(); // click on good option
207214
elmInput.sendKeys(protractor.Key.TAB);
215+
element(by.css('body')).click();
208216
}
209217

210218
var elmError = $('.validation-' + formElementNames[i]);
@@ -223,6 +231,7 @@
223231
// make input3 invalid, remove text
224232
var elmInput3 = $('[name=input3]');
225233
clearInput(elmInput3);
234+
element(by.css('body')).click();
226235
elmInput3.sendKeys(protractor.Key.TAB);
227236
//$('[for=input3]').click(); // click on label to blur away
228237

@@ -306,6 +315,7 @@
306315
it('Should focus and blur out of input22 & error should appear', function() {
307316
var elmInput = $('[name=input22]');
308317
elmInput.click();
318+
element(by.css('body')).click();
309319
elmInput.sendKeys(protractor.Key.TAB);
310320
//$('[for=input22]').click(); // click on label to blur away
311321

@@ -393,10 +403,12 @@
393403
var elmInput = $('[name=' + formElementNames[i] + ']');
394404
elmInput.click();
395405
elmInput.sendKeys(validInputTexts[i]);
406+
element(by.css('body')).click();
396407
elmInput.sendKeys(protractor.Key.TAB);
397408

398409
if (formElementNames[i] === 'select1') {
399410
element(by.cssContainingText('option', validInputTexts[i])).click(); // click on good option
411+
element(by.css('body')).click();
400412
elmInput.sendKeys(protractor.Key.TAB);
401413
}
402414

@@ -506,6 +518,7 @@
506518

507519
if (formElement2FormsNames[i] === 'select1') {
508520
element(by.cssContainingText('option', validInput2FormsTexts[i])).click(); // click on good option
521+
element(by.css('body')).click();
509522
elmInput.sendKeys(protractor.Key.TAB);
510523
}
511524

@@ -587,6 +600,7 @@
587600
var elmInput = $('[name=' + formElement2FormsNames[i] + ']');
588601
elmInput.click();
589602
elmInput.sendKeys("a");
603+
element(by.css('body')).click();
590604
elmInput.sendKeys(protractor.Key.TAB);
591605

592606
// both inputs should have the same error message

protractor/remote_spec.js

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
4343
var elmInput = $('[name=' + formElementNames[i] + ']');
4444
elmInput.click();
45+
element(by.css('body')).click();
4546
elmInput.sendKeys(protractor.Key.TAB);
4647

4748
var elmError = $('.validation-' + formElementNames[i]);
@@ -68,6 +69,7 @@
6869
clearInput(elmInput);
6970
elmInput.sendKeys(validInputTexts[i]);
7071
elmInput.sendKeys(protractor.Key.TAB);
72+
element(by.css('body')).click();
7173
browser.sleep(1000);
7274

7375
var elmError = $('.validation-' + formElementNames[i]);
@@ -108,6 +110,7 @@
108110
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
109111
var elmInput = $('[name=' + formElementNames[i] + ']');
110112
elmInput.click();
113+
element(by.css('body')).click();
111114
elmInput.sendKeys(protractor.Key.TAB);
112115

113116
var elmError = $('.validation-' + formElementNames[i]);

protractor/thirdParty_spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
elmInput.click();
7777
elmInput.sendKeys('tag4');
7878
elmInput.sendKeys(protractor.Key.ENTER);
79+
element(by.css('body')).click();
7980
elmInput.sendKeys(protractor.Key.TAB);
8081

8182
var elmError = $('.validation-input1');
@@ -92,6 +93,7 @@
9293
elmInput.click();
9394
elmInput.sendKeys('xyz');
9495
elmInput.sendKeys(protractor.Key.ENTER);
96+
element(by.css('body')).click();
9597
elmInput.sendKeys(protractor.Key.TAB);
9698

9799
// get 2 errors concatenated

protractor/validRequireHowMany_spec.js

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ describe('Angular-Validation ValidRequireHowMany Validation Tests:', function ()
3838
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
3939
var elmInput = $('[name=' + formElementNames[i] + ']');
4040
elmInput.click();
41+
element(by.css('body')).click();
4142
elmInput.sendKeys(protractor.Key.TAB);
4243

4344
var elmError = $('.validation-' + formElementNames[i]);
@@ -51,6 +52,7 @@ describe('Angular-Validation ValidRequireHowMany Validation Tests:', function ()
5152
elmInput.click();
5253
clearInput(elmInput);
5354
elmInput.sendKeys(invalidInputTexts[i]);
55+
element(by.css('body')).click();
5456
elmInput.sendKeys(protractor.Key.TAB);
5557

5658
var elmError = $('.validation-' + formElementNames[i]);
@@ -64,6 +66,7 @@ describe('Angular-Validation ValidRequireHowMany Validation Tests:', function ()
6466
elmInput.click();
6567
clearInput(elmInput);
6668
elmInput.sendKeys(validInputTexts[i]);
69+
element(by.css('body')).click();
6770
elmInput.sendKeys(protractor.Key.TAB);
6871

6972
var elmError = $('.validation-' + formElementNames[i]);
@@ -104,6 +107,7 @@ describe('Angular-Validation ValidRequireHowMany Validation Tests:', function ()
104107
for (var i = 0, ln = formElementNames.length; i < ln; i++) {
105108
var elmInput = $('[name=' + formElementNames[i] + ']');
106109
elmInput.click();
110+
element(by.css('body')).click();
107111
elmInput.sendKeys(protractor.Key.TAB);
108112

109113
var elmError = $('.validation-' + formElementNames[i]);

readme.md

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

src/validation-common.js

+2
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,8 @@ angular
612612
validationElmObj.message += errorMessageSeparator + msgToTranslate;
613613
}
614614
addToValidationAndDisplayError(self, formElmObj, validationElmObj.message, isFieldValid, showError);
615+
} else {
616+
throw String.format("Could not translate: '{0}'. Please check your Angular-Translate $translateProvider configuration.", data);
615617
}
616618
});
617619
})(formElmObj, isConditionValid, validator);

0 commit comments

Comments
 (0)