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

Commit fe72fc9

Browse files
committed
Fixed #92 name with dot, #94 Polish, #96 in_list
Fixed issue #92 input name with '.' was not working correctly on error message Issue #96 in_list was not accepting special characters. Enhancement #94 added Polish characters, thanks @Waniusza
1 parent ebdd789 commit fe72fc9

20 files changed

+71
-53
lines changed

app.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
149149
.addValidator({elmName: 'input18', rules: 'alpha_spaces|exact_len:3|required', debounce: 3000})
150150
.addValidator('input19', 'date_iso_min:2001-01-01|required')
151151
.addValidator('input20', 'date_us_short_between:11/28/99,12/31/15|required')
152-
.addValidator('input21', 'in_list:banana,orange,ice cream|required')
152+
.addValidator('input21', 'in_list:banana,orange,ice cream,sweet & sour|required')
153153
.addValidator('area1', 'alpha_dash_spaces|min_len:15|required')
154154
.addValidator('input22', 'alpha_dash|min_len:2|required');
155155

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

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Angular-Validation change logs
22

3+
1.4.17 (2015-12-15) Fixed issue #92 input name with '.', enhancement #94 Polish characters, issue #96 in_list wasn't accepting special characters.
34
1.4.16 (2015-12-11) Fixed issue #90 blinking error messages.
45
1.4.15 (2015-12-02) Fixed issue #86 implicit global variable on regex.
56
1.4.14 (2015-11-15) Added validation-callback (#79), added #81, #82. Added new validation-callback attribute, runs after the debounce/blur and validaiton are completed. Added possibility passing arguments to Custom & Remote validators. Added new Global Options: hideErrorUnderInputs.

dist/angular-validation.min.js

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

full-tests/app.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ function loadData() {
284284
{
285285
'validator': 'in',
286286
'aliases': ['inList', 'in_list'],
287-
'params': 'chocolate,apple pie,ice cream'
287+
'params': 'chocolate,apple pie,ice cream,sweet & sour,A+B'
288288
},
289289
{
290290
'validator': 'int',
@@ -324,7 +324,7 @@ function loadData() {
324324
{
325325
'validator': 'notIn',
326326
'aliases': ['not_in', 'notInList', 'not_in_list'],
327-
'params': 'chocolate,apple pie,ice cream'
327+
'params': 'chocolate,apple pie,ice cream,sweet & sour,A+B'
328328
},
329329
{
330330
'validator': 'numeric'

locales/validation/en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alphanumeric + Exactly(3) + Required -- debounce(3sec)",
8686
"INPUT19": "Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01 ",
8787
"INPUT20": "Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15",
88-
"INPUT21": "Choice IN this list (banana,orange,ice cream)",
88+
"INPUT21": "Choice IN this list (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "First Name",
9090
"LAST_NAME": "Last Name",
9191
"RESET_FORM": "Reset Form",

locales/validation/es.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alfanúmerico + Exactamente(3) + Requerido -- debounce(3sec)",
8686
"INPUT19": "Fecha formato ISO (yyyy-mm-dd) -- Condición mínima >= 2001-01-01 ",
8787
"INPUT20": "Fecha formato US corto (mm/dd/yy) -- entre las fechas 12/01/99 and 12/31/15",
88-
"INPUT21": "Elección en esta lista (banana,orange,ice cream)",
88+
"INPUT21": "Elección en esta lista (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Nombre",
9090
"LAST_NAME": "Apellido",
9191
"RESET_FORM": "Cambiar la Forma",

locales/validation/fr.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alphanumérique + Exactement(3) + Requis -- debounce(3sec)",
8686
"INPUT19": "Date ISO (aaaa-mm-jj ) -- condition minimal >= 2001-01-01 ",
8787
"INPUT20": "Date US COURT (mm/jj/aa) -- entre les dates 12/01/99 et 12/31/15",
88-
"INPUT21": "Choix dans cette liste (banana,orange,ice cream)",
88+
"INPUT21": "Choix dans cette liste (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Prénom",
9090
"LAST_NAME": "Nom de Famille",
9191
"RESET_FORM": "Réinitialisation le formulaire",

locales/validation/no.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alfanumerisk + Nøyaktig(3) + Påkrevd -- debounce(3sec)",
8686
"INPUT19": "ISO dato (yyyy-mm-dd) -- minimum >= 2001-01-01 ",
8787
"INPUT20": "US SHORT dato (mm/dd/yy) -- mellom 12/01/99 og 12/31/15",
88-
"INPUT21": "Valget i denne listen (banana,orange,ice cream)",
88+
"INPUT21": "Valget i denne listen (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Fornavn",
9090
"LAST_NAME": "Etternavn",
9191
"RESET_FORM": "Nullstill skjemaet",

locales/validation/pl.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alfanumeryczne + Dokładnie(3) + Wymaganae -- debounce(3sec)",
8686
"INPUT19": "Data w formacie ISO (rrrr-mm-dd) -- warunek minimum >= 2001-01-01 ",
8787
"INPUT20": "Data w formacie US SHORT (mm/dd/rr) -- pomiędzy datami 12/01/99 a 12/31/15",
88-
"INPUT21": "Wybór w tej liście (banana,orange,ice cream)",
88+
"INPUT21": "Wybór w tej liście (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Imię",
9090
"LAST_NAME": "Nazwisko",
9191
"RESET_FORM": "Zresetować formularz",

locales/validation/pt-br.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Alphanumeric + Exactly(3) + Required -- debounce(3sec)",
8686
"INPUT19": "Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01 ",
8787
"INPUT20": "Date US SHORT (mm/dd/yy) -- entre the dates 12/01/99 and 12/31/15",
88-
"INPUT21": "Escolha nesta lista (banana,orange,ice cream)",
88+
"INPUT21": "Escolha nesta lista (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Primeiro nome",
9090
"LAST_NAME": "Último nome",
9191
"RESET_FORM": "Limpar formulário",

locales/validation/ru.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"INPUT18": "Буквенно-цифровой + Точно(3) + Обязательно -- debounce(3sec)",
8686
"INPUT19": "Дата ISO (yyyy-mm-dd) -- минимальное условие >= 2001-01-01 ",
8787
"INPUT20": "Дата US SHORT (mm/dd/yy) --между датами 12/01/99 и 12/31/15",
88-
"INPUT21": "Выбор в этом списке (banana,orange,ice cream)",
88+
"INPUT21": "Выбор в этом списке (banana,orange,ice cream,sweet & sour)",
8989
"FIRST_NAME": "Имя",
9090
"LAST_NAME": "Фамилия",
9191
"RESET_FORM": "Сброс форму",

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

protractor/full_tests_spec.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,15 @@ function loadData() {
652652
{
653653
'validator': 'in',
654654
'aliases': ['inList', 'in_list'],
655-
'params': 'chocolate,apple pie,ice cream',
655+
'params': 'chocolate,apple pie,ice cream,sweet & sour,A+B',
656656
'invalid_data': ['choco', 'carrot', 'apple'],
657-
'valid_data': ['chocolate', 'apple pie', 'ice cream'],
657+
'valid_data': ['chocolate', 'ice cream','sweet & sour','A+B'],
658658
'error_message': {
659-
'en': "Must be a choice inside this list: (chocolate,apple pie,ice cream).",
660-
'es': "Debe ser una opción dentro de esta lista: (chocolate,apple pie,ice cream).",
661-
'fr': "Doit être un choix dans cette liste: (chocolate,apple pie,ice cream).",
662-
'no': "Må være et valg inne i denne listen: (chocolate,apple pie,ice cream).",
663-
'ru': "Должно бытьвыбор в этом списке: (chocolate,apple pie,ice cream)."
659+
'en': "Must be a choice inside this list: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
660+
'es': "Debe ser una opción dentro de esta lista: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
661+
'fr': "Doit être un choix dans cette liste: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
662+
'no': "Må være et valg inne i denne listen: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
663+
'ru': "Должно бытьвыбор в этом списке: (chocolate,apple pie,ice cream,sweet & sour,A+B)."
664664
}
665665
},
666666
{
@@ -773,15 +773,15 @@ function loadData() {
773773
{
774774
'validator': 'notIn',
775775
'aliases': ['not_in', 'notInList', 'not_in_list'],
776-
'params': 'chocolate,apple pie,ice cream',
777-
'invalid_data': ['chocolate', 'apple pie', 'ice cream'],
778-
'valid_data': ['choco', 'carrot', 'apple'],
779-
'error_message': {
780-
'en': "Must be a choice outside this list: (chocolate,apple pie,ice cream).",
781-
'es': "Debe ser una elección fuera de esta lista: (chocolate,apple pie,ice cream).",
782-
'fr': "Doit être un choix en dehors de cette liste: (chocolate,apple pie,ice cream).",
783-
'no': "Må være et valg utenfor denne listen: (chocolate,apple pie,ice cream).",
784-
'ru': "Должно бытьвыбор за этот список: (chocolate,apple pie,ice cream)."
776+
'params': 'chocolate,apple pie,ice cream,sweet & sour,A+B',
777+
'invalid_data': ['chocolate', 'apple pie', 'sweet & sour', 'A+B'],
778+
'valid_data': ['apple', 'sweet & sou', 'A+', 'B+A'],
779+
'error_message': {
780+
'en': "Must be a choice outside this list: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
781+
'es': "Debe ser una elección fuera de esta lista: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
782+
'fr': "Doit être un choix en dehors de cette liste: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
783+
'no': "Må være et valg utenfor denne listen: (chocolate,apple pie,ice cream,sweet & sour,A+B).",
784+
'ru': "Должно бытьвыбор за этот список: (chocolate,apple pie,ice cream,sweet & sour,A+B)."
785785
}
786786
},
787787
{

protractor/mixed_validation_spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"Alphanumeric + Exactly(3) + Required -- debounce(3sec)",
2424
"Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01",
2525
"Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15",
26-
"Choice IN this list (banana,orange,ice cream)",
26+
"Choice IN this list (banana,orange,ice cream,sweet & sour)",
2727
"TextArea: Alphanumeric + Minimum(15) + Required",
2828
"Input22 - ngDisabled =>"
2929
];
@@ -48,7 +48,7 @@
4848
"May only contain letters and spaces. Must have a length of exactly 3 characters. Field is required.",
4949
"Needs to be a valid date format (yyyy-mm-dd), equal to, or higher than 2001-01-01. Field is required.",
5050
"Needs to be a valid date format (mm/dd/yy) OR (mm-dd-yy) between 11/28/99 and 12/31/15. Field is required.",
51-
"Must be a choice inside this list: (banana,orange,ice cream). Field is required.",
51+
"Must be a choice inside this list: (banana,orange,ice cream,sweet & sour). Field is required.",
5252
"May only contain letters, numbers, dashes and spaces. Must be at least 15 characters. Field is required."
5353
];
5454
var validInputTexts = [
@@ -72,7 +72,7 @@
7272
"abc",
7373
"2001-01-01",
7474
"01/01/12",
75-
"ice cream",
75+
"sweet & sour",
7676
"This is a great tool"
7777
];
7878
var types = ['Directive', 'Service'];

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Angular Validation (Directive / Service)
2-
`Version: 1.4.16`
2+
`Version: 1.4.17`
33
### Form validation after user stop typing (default 1sec).
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!

src/validation-common.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ angular
8787
validationCommon.prototype.validate = validate; // validate current element
8888

8989
// override some default String functions
90-
String.prototype.trim = stringPrototypeTrim;
91-
String.prototype.format = stringPrototypeFormat;
92-
String.format = stringFormat;
93-
90+
String.prototype.trim = stringPrototypeTrim; // extend String object to have a trim function
91+
String.prototype.format = stringPrototypeFormat; // extend String object to have a format function like C#
92+
String.format = stringFormat; // extend String object to have a format function like C#
9493
// return the service object
9594
return validationCommon;
9695

@@ -457,7 +456,8 @@ angular
457456
var errorMsg = (!!attrs && !!attrs.translate) ? $translate.instant(message) : message;
458457

459458
// get the name attribute of current element, make sure to strip dirty characters, for example remove a <input name="options[]"/>, we need to strip the "[]"
460-
var elmInputName = elmName.replace(/[|&;$%@"<>()+,\[\]\{\}]/g, '');
459+
// also replace any possible '.' inside the input name by '-'
460+
var elmInputName = elmName.replace(/[|&;$%@"<>()+,\[\]\{\}]/g, '').replace(/\./g, '-');
461461
var errorElm = null;
462462

463463
// find the element which we'll display the error message, this element might be defined by the user with 'validationErrorTo'

src/validation-rules.js

+27-10
Original file line numberDiff line numberDiff line change
@@ -46,47 +46,47 @@ angular
4646
break;
4747
case "alpha" :
4848
validator = {
49-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ])+$/i,
49+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ])+$/i,
5050
message: "INVALID_ALPHA",
5151
type: "regex"
5252
};
5353
break;
5454
case "alphaSpaces" :
5555
case "alpha_spaces" :
5656
validator = {
57-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ\s])+$/i,
57+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ\s])+$/i,
5858
message: "INVALID_ALPHA_SPACE",
5959
type: "regex"
6060
};
6161
break;
6262
case "alphaNum" :
6363
case "alpha_num" :
6464
validator = {
65-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ0-9])+$/i,
65+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9])+$/i,
6666
message: "INVALID_ALPHA_NUM",
6767
type: "regex"
6868
};
6969
break;
7070
case "alphaNumSpaces" :
7171
case "alpha_num_spaces" :
7272
validator = {
73-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ0-9\s])+$/i,
73+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s])+$/i,
7474
message: "INVALID_ALPHA_NUM_SPACE",
7575
type: "regex"
7676
};
7777
break;
7878
case "alphaDash" :
7979
case "alpha_dash" :
8080
validator = {
81-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ0-9_-])+$/i,
81+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9_-])+$/i,
8282
message: "INVALID_ALPHA_DASH",
8383
type: "regex"
8484
};
8585
break;
8686
case "alphaDashSpaces" :
8787
case "alpha_dash_spaces" :
8888
validator = {
89-
pattern: /^([a-zа-яàáâãäåæçèéêëœìíïîðòóôõöøùúûñüýÿßÞďđ0-9\s_-])+$/i,
89+
pattern: /^([a-zа-яàáâãäåąæçćèéêëęœìíïîłńðòóôõöøśùúûñüýÿżźßÞďđ0-9\s_-])+$/i,
9090
message: "INVALID_ALPHA_DASH_SPACE",
9191
type: "regex"
9292
};
@@ -491,9 +491,9 @@ angular
491491
case "in" :
492492
case "inList" :
493493
case "in_list" :
494-
var list = ruleParams.replace(/,/g, '|'); // replace comma (,) by pipe (|)
494+
var list = RegExp().escape(ruleParams).replace(/,/g, '|'); // escape string & replace comma (,) by pipe (|)
495495
validator = {
496-
pattern: "^(\\b(" + list + ")\\b)$",
496+
pattern: "^(" + list + ")$",
497497
patternFlag: 'i',
498498
message: "INVALID_IN_LIST",
499499
params: [ruleParams],
@@ -605,9 +605,9 @@ angular
605605
case "not_in" :
606606
case "notInList" :
607607
case "not_in_list" :
608-
var list = ruleParams.replace(/,/g, '|'); // replace comma (,) by pipe (|)
608+
var list = RegExp().escape(ruleParams).replace(/,/g, '|'); // escape string & replace comma (,) by pipe (|)
609609
validator = {
610-
pattern: "^((?!\\b(" + list + ")\\b).)+$",
610+
pattern: "^((?!(" + list + ")).)+$",
611611
patternFlag: 'i',
612612
message: "INVALID_NOT_IN_LIST",
613613
params: [ruleParams],
@@ -685,3 +685,20 @@ angular
685685
return validator;
686686
} // getElementValidators()
687687
}]);
688+
689+
/** extend RegExp object to have an escape function
690+
* @param string text
691+
* @return escaped string
692+
*/
693+
RegExp.prototype.escape = function(text) {
694+
if (!arguments.callee.sRE) {
695+
var specials = [
696+
'/', '.', '*', '+', '?', '|',
697+
'(', ')', '[', ']', '{', '}', '\\'
698+
];
699+
arguments.callee.sRE = new RegExp(
700+
'(\\' + specials.join('|\\') + ')', 'g'
701+
);
702+
}
703+
return text.replace(arguments.callee.sRE, '\\$1');
704+
}

templates/testingFormDirective.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h4><strong>{{ 'ERRORS' | translate }}!</strong></h4>
136136
</div>
137137
<div class="form-group">
138138
<label for="input21">{{ 'INPUT21' | translate }}</label>
139-
<input type="text" class="form-control" name="input21" placeholder="in_list:banana,orange,ice cream|required" ng-model="input21" validation="in_list:banana,orange,ice cream|required" />
139+
<input type="text" class="form-control" name="input21" placeholder="in_list:banana,orange,ice cream,sweet &amp; sour|required" ng-model="input21" validation="in_list:banana,orange,ice cream,sweet &amp; sour|required" />
140140
</div>
141141
<div class="form-group">
142142
<label for="area1">{{ 'AREA1' | translate }}</label>

templates/testingFormService.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ <h4><strong>{{ 'ERRORS' | translate }}!</strong></h4>
136136
</div>
137137
<div class="form-group">
138138
<label for="input21">{{ 'INPUT21' | translate }}</label>
139-
<input type="text" class="form-control" name="input21" placeholder="in_list:banana,orange,berry|required" ng-model="input21" />
139+
<input type="text" class="form-control" name="input21" placeholder="in_list:banana,orange,ice cream,sweet &amp; sour|required" ng-model="input21" />
140140
</div>
141141
<div class="form-group">
142142
<label for="area1">{{ 'AREA1' | translate }}</label>

0 commit comments

Comments
 (0)