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

Commit b58fbc1

Browse files
committed
Rewrote custom Regex Pattern and fixed issue #45
- Deprecated old implentation of `regex:...:regex` (though it still works) by a new and much better implementation of `pattern=` validator. - Converted all the rules from string pattern to regex pattern (when possible) defined in `angular-validation.js`. - Also fixed issue #45 on email check.
1 parent 9c943c6 commit b58fbc1

17 files changed

+114
-75
lines changed

app.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ myApp.controller('Ctrl', ['$location', '$route', '$scope', '$translate', functio
3838
// -- Controller to use Angular-Validation Directive
3939
// -----------------------------------------------
4040
myApp.controller('CtrlValidationDirective', ['$q', '$scope', 'validationService', function ($q, $scope, validationService) {
41-
$scope.$validationOptions = { debounce: 1500, preValidateFormElements: false }; // you can change default debounce globally
41+
// you can change default debounce globally
42+
$scope.$validationOptions = { debounce: 1500, preValidateFormElements: false };
43+
44+
// if we want to use the invalid_pattern_data locale translation as an alternateText (:alt=)
45+
// then we need to supply an extra 'data' variable (as defined in the JSON locale) of what we expect the search pattern on our input4
46+
$scope.translationData = { data: 'YYWW' };
4247

4348
// remove a single element ($scope.form1, string)
4449
// OR you can also remove multiple elements through an array type .removeValidator($scope.form1, ['input2','input3'])
@@ -122,7 +127,7 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
122127
.setGlobalOptions({ debounce: 1500, scope: $scope, isolatedScope: $scope, preValidateFormElements: false, displayOnlyLastErrorMsg: false })
123128
.addValidator({ elmName: 'input2', debounce: 3000, rules: 'numeric_signed|required'})
124129
.addValidator('input3', 'float_signed|between_num:-0.6,99.5|required')
125-
.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')
130+
.addValidator('input4', 'exact_len:4|pattern=/^(0[9]|1[0-9]|2[0-9]|3[0-9])(5[0-2]|[0-4][0-9])$/:alt=' + $translate.instant('INVALID_PATTERN_DATA', { data: 'YYWW' }) + '|required|integer')
126131
.addValidator('input5', 'email|required|min_len:6', $translate.instant('INPUT5')) // 3rd argument being the Friendly name
127132
.addValidator('input6', 'url|required')
128133
.addValidator('input7', 'ipv4|required')

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

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Angular-Validation change logs
22

3+
1.3.35 (2015-07-15) Deprecated old implentation of `regex:...:regex` (though it still works) by a new and much better implementation of `pattern=` validator. Converted all the rules from string pattern to regex pattern (when possible) defined in `angular-validation.js`. Also fixed issue #45 on email check.
34
1.3.34 (2015-07-08) Merge pull request #44 - Adding support to brazilian portuguese language.
45
1.3.33 (2015-07-02) Reset isolatedScope on route change
56
1.3.32 (2015-06-24) Merged pull request #41 and fixed errors inside it, updated Protractor test as well.

dist/angular-validation.min.js

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

locales/validation/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Must be a positive number. ",
4949
"INVALID_NUMERIC_SIGNED": "Must be a positive or negative number. ",
5050
"INVALID_PATTERN": "Must be following this format: {0}. ",
51+
"INVALID_PATTERN_DATA": "Must be following this format \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Field is required. ",
5253
"INVALID_URL": "Must be a valid URL. ",
5354
"INVALID_TIME": "Must be a valid time format (hh:mm) OR (hh:mm:ss). ",

locales/validation/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Doit être un nombre positif. ",
4949
"INVALID_NUMERIC_SIGNED": "Doit être un nombre positif ou négatif. ",
5050
"INVALID_PATTERN": "Doit suivre le format: {0}. ",
51+
"INVALID_PATTERN_DATA": "Doit suivre le format \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Le champ est requis. ",
5253
"INVALID_URL": "Doit être un URL valide. ",
5354
"INVALID_TIME": "Doit être un format de temps valide (hh:mm) OU (hh:mm:ss). ",

locales/validation/no.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Må være et positivt tall. ",
4949
"INVALID_NUMERIC_SIGNED": "Må være et positivt eller negativt tall. ",
5050
"INVALID_PATTERN": "Må være på følgende format: {0}. ",
51+
"INVALID_PATTERN_DATA": "Må være på følgende format \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Feltet er påkrevd. ",
5253
"INVALID_URL": "Må være en gyldig URL. ",
5354
"INVALID_TIME": "Må være et gyldig tidsformat (tt:mm) OR (tt:mm:ss). ",

locales/validation/pl.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Musi być liczbą dodatnią. ",
4949
"INVALID_NUMERIC_SIGNED": "Musi być liczbą dodatnią lub ujemną. ",
5050
"INVALID_PATTERN": "Musi być zgodne z formatem: {0}. ",
51+
"INVALID_PATTERN_DATA": "Musi być zgodne z formatem \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Pole jest wymagane. ",
5253
"INVALID_URL": "Musi być poprawnym adresem URL. ",
5354
"INVALID_TIME": "Musi być poprawną godziną w formacie (gg:mm) OR (gg:mm:ss). ",

locales/validation/pt-br.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Deve ser um número positivo. ",
4949
"INVALID_NUMERIC_SIGNED": "Deve ser um número positivo ou negativo. ",
5050
"INVALID_PATTERN": "Deve seguir o seguinte formato: {0}. ",
51+
"INVALID_PATTERN_DATA": "Deve seguir o seguinte formato \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Campo obrigatório. ",
5253
"INVALID_URL": "Deve ser uma URL válida. ",
5354
"INVALID_TIME": "Deve ser um formato de hora válido (hh:mm) ou (hh:mm:ss). ",

locales/validation/ru.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"INVALID_NUMERIC": "Должно быть положительным числом. ",
4949
"INVALID_NUMERIC_SIGNED": "Должно быть положительным или отрицательным числом. ",
5050
"INVALID_PATTERN": "Должно соответствовать этому формату: {0}. ",
51+
"INVALID_PATTERN_DATA": "Должно соответствовать этому формату \"{{data}}\". ",
5152
"INVALID_REQUIRED": "Поле обязательно для заполнения. ",
5253
"INVALID_URL": "Должно быть действительным URL адресом. ",
5354
"INVALID_TIME": "Должно быть допустимым форматом времени (hh:mm) или (hh:mm:ss). ",

0 commit comments

Comments
 (0)