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

Commit 82a1120

Browse files
committed
Enhancement #59 - Added few new Laravel Validators
Added few Validators that are like Laravel for reusability. The `in` and `not_in` Validators are the most interesting. The list includes: - accepted: useful on "Terms of service" - between: auto-detect type then use between_len or between_num - max: auto-detect type then use max_len or max_num - min: auto-detect type then use min_len or min_num - size: auto-detect type then use exact_len or exact_num - ip: new alias - digits: similar to exact_len but only for digits - digits_between: similar to between_len but only for digits - in / in_list: useful for accepting a word from a given list of values - not_in / not_in_list: useful for accepting a word outside a given list of values - different: make sure current input is different from another input - same: new alias to match
1 parent dbd7e38 commit 82a1120

22 files changed

+506
-136
lines changed

app.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ myApp.controller('CtrlValidationService', ['$q', '$scope', '$translate', 'valida
144144
.addValidator('input14', 'alpha|required')
145145
.addValidator('input15', 'alpha|min_len:3|required')
146146
.addValidator('input16', 'match:input15,Password|required')
147-
.addValidator({elmName: 'input17', rules: 'alpha_spaces|exact_len:3|required', debounce: 3000})
148-
.addValidator('input18', 'date_iso_min:2001-01-01|required')
149-
.addValidator('input19', 'date_us_short_between:11/28/99,12/31/15|required')
147+
.addValidator('input17', 'different:input15,Password|required')
148+
.addValidator({elmName: 'input18', rules: 'alpha_spaces|exact_len:3|required', debounce: 3000})
149+
.addValidator('input19', 'date_iso_min:2001-01-01|required')
150+
.addValidator('input20', 'date_us_short_between:11/28/99,12/31/15|required')
151+
.addValidator('input21', 'in_list:banana,orange,ice cream|required')
150152
.addValidator('area1', 'alpha_dash_spaces|min_len:15|required')
151-
.addValidator('input20', 'alpha_dash|min_len:2|required');
153+
.addValidator('input22', 'alpha_dash|min_len:2|required');
152154

153155
// remove a single element ($scope.form1, string)
154156
// OR you can also remove multiple elements through an array type .removeValidator($scope.form1, ['input2','input3'])

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.4.3",
3+
"version": "1.4.4",
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.4.4 (2015-08-21) Enhancement #59 - Added few Validators that are like Laravel for reusability. The `in` and `not_in` Validators are the most interesting.
34
1.4.3 (2015-08-18) Fixed issue #58 - multiple ControllerAs with Route change giving error of 'undefined' on $validationSummary.
45
1.4.2 (2015-08-09) Fixed Bootstrap UI (or any other tool) interference with Angular-Validation, in relation to issue #55.
56
1.4.1 (2015-08-09) Fixed issue #56 - TextArea validation problem with ENTER key (newline).

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.

full-tests/Service.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,47 @@ <h4><strong>{{ 'ERRORS' | translate }}!</strong></h4>
487487
<label for="input116">input116</label>
488488
<input class="form-control" type="text" name="input116" ng-model="input116">
489489
</div>
490+
<div class="form-group row">
491+
<label for="input117">input117</label>
492+
<input class="form-control" type="text" name="input117" ng-model="input117">
493+
</div>
494+
<div class="form-group row">
495+
<label for="input118">input118</label>
496+
<input class="form-control" type="text" name="input118" ng-model="input118">
497+
</div>
498+
<div class="form-group row">
499+
<label for="input119">input119</label>
500+
<input class="form-control" type="text" name="input119" ng-model="input119">
501+
</div>
502+
<div class="form-group row">
503+
<label for="input120">input120</label>
504+
<input class="form-control" type="text" name="input120" ng-model="input120">
505+
</div>
506+
<div class="form-group row">
507+
<label for="input121">input121</label>
508+
<input class="form-control" type="text" name="input121" ng-model="input121">
509+
</div>
510+
<div class="form-group row">
511+
<label for="input122">input122</label>
512+
<input class="form-control" type="text" name="input122" ng-model="input122">
513+
</div>
514+
<div class="form-group row">
515+
<label for="input123">input123</label>
516+
<input class="form-control" type="text" name="input123" ng-model="input123">
517+
</div>
518+
<div class="form-group row">
519+
<label for="input124">input124</label>
520+
<input class="form-control" type="text" name="input124" ng-model="input124">
521+
</div>
522+
<div class="form-group row">
523+
<label for="input125">input125</label>
524+
<input class="form-control" type="text" name="input125" ng-model="input125">
525+
</div>
526+
<div class="form-group row">
527+
<label for="input126">input126</label>
528+
<input class="form-control" type="text" name="input126" ng-model="input126">
529+
</div>
530+
490531
</fieldset>
491532

492533
<div class="form-actions">

full-tests/app.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ function loadData() {
254254
'aliases': ['date_us_short_min', 'minDateUsShort', 'min_date_us_short'],
255255
'params': '01/01/90'
256256
},
257+
{
258+
'validator': 'digits',
259+
'params': '3'
260+
},
261+
{
262+
'validator': 'digitsBetween',
263+
'aliases': ['digits_between'],
264+
'params': '1,5'
265+
},
257266
{
258267
'validator': 'email'
259268
},
@@ -272,6 +281,11 @@ function loadData() {
272281
{
273282
'validator': 'iban'
274283
},
284+
{
285+
'validator': 'in',
286+
'aliases': ['inList', 'in_list'],
287+
'params': 'chocolate,apple pie,ice cream'
288+
},
275289
{
276290
'validator': 'int',
277291
'aliases': ['integer']
@@ -281,7 +295,8 @@ function loadData() {
281295
'aliases': ['integerSigned', 'int_signed', 'integer_signed']
282296
},
283297
{
284-
'validator': 'ipv4'
298+
'validator': 'ipv4',
299+
'aliases': ['ip']
285300
},
286301
{
287302
'validator': 'ipv6'
@@ -306,16 +321,18 @@ function loadData() {
306321
'aliases': ['min_num'],
307322
'params': '1'
308323
},
324+
{
325+
'validator': 'notIn',
326+
'aliases': ['not_in', 'notInList', 'not_in_list'],
327+
'params': 'chocolate,apple pie,ice cream'
328+
},
309329
{
310330
'validator': 'numeric'
311331
},
312332
{
313333
'validator': 'numericSigned',
314334
'aliases': ['numeric_signed']
315335
},
316-
{
317-
'validator': 'required'
318-
},
319336
{
320337
'validator': 'url'
321338
},

locales/validation/en.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"INVALID_ACCEPTED": "Must be accepted. ",
23
"INVALID_ALPHA": "May only contain letters. ",
34
"INVALID_ALPHA_SPACE": "May only contain letters and spaces. ",
45
"INVALID_ALPHA_NUM": "May only contain letters and numbers. ",
@@ -29,12 +30,17 @@
2930
"INVALID_DATE_US_SHORT_BETWEEN": "Needs to be a valid date format (mm/dd/yy) OR (mm-dd-yy) between {0} and {1}. ",
3031
"INVALID_DATE_US_SHORT_MAX": "Needs to be a valid date format (mm/dd/yy) OR (mm-dd-yy), equal to, or lower than {0}. ",
3132
"INVALID_DATE_US_SHORT_MIN": "Needs to be a valid date format (mm/dd/yy) OR (mm-dd-yy), equal to, or higher than {0}. ",
33+
"INVALID_DIGITS": "Must be {0} digits. ",
34+
"INVALID_DIGITS_BETWEEN": "Must be between {0} and {1} digits. ",
3235
"INVALID_EMAIL": "Must be a valid email address. ",
3336
"INVALID_EXACT_LEN": "Must have a length of exactly {0} characters. ",
37+
"INVALID_EXACT_NUM": "Must be exactly {0}. ",
3438
"INVALID_FLOAT": "May only contain a positive float value (integer excluded). ",
3539
"INVALID_FLOAT_SIGNED": "May only contain a positive or negative float value (integer excluded). ",
3640
"INVALID_IBAN": "Must be a valid IBAN. ",
37-
"INVALID_INPUT_MATCH": "Confirmation field does not match specified field \"{0}\". ",
41+
"INVALID_IN_LIST": "Must be a choice inside this list: ({0}). ",
42+
"INVALID_INPUT_DIFFERENT": "Field must be different from specified field \"{1}\". ",
43+
"INVALID_INPUT_MATCH": "Confirmation field does not match specified field \"{1}\". ",
3844
"INVALID_INTEGER": "Must be a positive integer. ",
3945
"INVALID_INTEGER_SIGNED": "Must be a positive or negative integer. ",
4046
"INVALID_IPV4": "Must be a valid IP (IPV4). ",
@@ -45,6 +51,7 @@
4551
"INVALID_MAX_NUM": "Needs to be a numeric value, equal to, or lower than {0}. ",
4652
"INVALID_MIN_CHAR": "Must be at least {0} characters. ",
4753
"INVALID_MIN_NUM": "Needs to be a numeric value, equal to, or higher than {0}. ",
54+
"INVALID_NOT_IN_LIST": "Must be a choice outside this list: ({0}). ",
4855
"INVALID_NUMERIC": "Must be a positive number. ",
4956
"INVALID_NUMERIC_SIGNED": "Must be a positive or negative number. ",
5057
"INVALID_PATTERN": "Must be following this format: {0}. ",
@@ -74,9 +81,11 @@
7481
"INPUT14": "Alphanumeric + Required -- NG-DISABLED",
7582
"INPUT15": "Password",
7683
"INPUT16": "Password Confirmation",
77-
"INPUT17": "Alphanumeric + Exactly(3) + Required -- debounce(3sec)",
78-
"INPUT18": "Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01 ",
79-
"INPUT19": "Date US SHORT (mm/dd/yy) -- between the dates 12/01/99 and 12/31/15",
84+
"INPUT17": "Different Password",
85+
"INPUT18": "Alphanumeric + Exactly(3) + Required -- debounce(3sec)",
86+
"INPUT19": "Date ISO (yyyy-mm-dd) -- minimum condition >= 2001-01-01 ",
87+
"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)",
8089
"FIRST_NAME": "First Name",
8190
"LAST_NAME": "Last Name",
8291
"RESET_FORM": "Reset Form",

locales/validation/es.json

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"INVALID_ACCEPTED": "Debe ser aceptado. ",
23
"INVALID_ALPHA": "Unicamente puede contener letras. ",
34
"INVALID_ALPHA_SPACE": "Unicamente puede contener letras y espacios. ",
45
"INVALID_ALPHA_NUM": "Unicamente puede contener letras y números. ",
@@ -29,12 +30,17 @@
2930
"INVALID_DATE_US_SHORT_BETWEEN": "Debe contener una fecha valida entre {0} y {1} con formato (mm/dd/yy) ó (mm/dd/yy). ",
3031
"INVALID_DATE_US_SHORT_MAX": "Debe contener una fecha valida igual ó menor que {0} con formato (mm/dd/yy) ó (mm/dd/yy). ",
3132
"INVALID_DATE_US_SHORT_MIN": "Debe contener una fecha valida igual ó mayor que {0} con formato (mm/dd/yy) ó (mm/dd/yy). ",
33+
"INVALID_DIGITS": "Debe ser {0} dígitos. ",
34+
"INVALID_DIGITS_BETWEEN": "Debe ser entre {0} y {1} dígitos. ",
3235
"INVALID_EMAIL": "Debe contener una dirección de correo electronico valida. ",
3336
"INVALID_EXACT_LEN": "Debe contener exactamente {0} caracteres. ",
37+
"INVALID_EXACT_NUM": "Debe ser exactamente {0}. ",
3438
"INVALID_FLOAT": "Debe contener un número decimal positivo (Los números enteros no son validos). ",
3539
"INVALID_FLOAT_SIGNED": "Debe contener un número decimal positivo ó negativo (Los números enteros no son validos). ",
3640
"INVALID_IBAN": "Debe contener un IBAN valido. ",
37-
"INVALID_INPUT_MATCH": "El campo de confirnmación no coincide con el texto especificado \"{0}\". ",
41+
"INVALID_IN_LIST": "Debe ser una opción dentro de esta lista: ({0}). ",
42+
"INVALID_INPUT_DIFFERENT": "El campo debe ser diferente de la \"{1}\" campo especificado. ",
43+
"INVALID_INPUT_MATCH": "El campo de confirnmación no coincide con el texto especificado \"{1}\". ",
3844
"INVALID_INTEGER": "Debe contener un número entero positivo. ",
3945
"INVALID_INTEGER_SIGNED": "Debe contener un número entero positivo ó negativo. ",
4046
"INVALID_IPV4": "Debe contener una dirección IP valida (IPV4). ",
@@ -45,6 +51,7 @@
4551
"INVALID_MAX_NUM": "Debe contener un valor númerico igual o menor que {0}. ",
4652
"INVALID_MIN_CHAR": "Debe contener almenos {0} caracteres. ",
4753
"INVALID_MIN_NUM": "Debe contener un valor númerico igual o mayor que {0}. ",
54+
"INVALID_NOT_IN_LIST": "Debe ser una elección fuera de esta lista: ({0}). ",
4855
"INVALID_NUMERIC": "Debe contener un valor númerico positivo. ",
4956
"INVALID_NUMERIC_SIGNED": "Debe contener un valor númerico positivo ó negativo. ",
5057
"INVALID_PATTERN": "Debe contener un texto con el formato: {0}. ",
@@ -72,10 +79,12 @@
7279
"INPUT13": "AlphaDashSpaces + Requerido + Minimo(5) Caracteres -- Deben ser: validation-error-to=\" \"",
7380
"INPUT14": "Alfanúmerico + Requerido -- NG-DISABLED",
7481
"INPUT15": "Contraseña",
75-
"INPUT16": "Confirmación de contraseña",
76-
"INPUT17": "Alfanúmerico + Exactamente(3) + Requerido -- debounce(3sec)",
77-
"INPUT18": "Fecha formato ISO (yyyy-mm-dd) -- Condición minima >= 2001-01-01 ",
78-
"INPUT19": "Fecha formato US corto (mm/dd/yy) -- entre las fechas 12/01/99 and 12/31/15",
82+
"INPUT16": "Confirmación de Contraseña",
83+
"INPUT17": "Diferente Contraseña",
84+
"INPUT18": "Alfanúmerico + Exactamente(3) + Requerido -- debounce(3sec)",
85+
"INPUT19": "Fecha formato ISO (yyyy-mm-dd) -- Condición minima >= 2001-01-01 ",
86+
"INPUT20": "Fecha formato US corto (mm/dd/yy) -- entre las fechas 12/01/99 and 12/31/15",
87+
"INPUT21": "Elección en esta lista (banana,orange,ice cream)",
7988
"FIRST_NAME": "Nombre",
8089
"LAST_NAME": "Apellido",
8190
"RESET_FORM": "Cambiar la Forma",

locales/validation/fr.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"INVALID_ACCEPTED": "Doit être accepté. ",
23
"INVALID_ALPHA": "Ne doit contenir que des lettres. ",
34
"INVALID_ALPHA_SPACE": "Ne doit contenir que des lettres et espaces. ",
45
"INVALID_ALPHA_NUM": "Ne doit contenir que des lettres et nombres. ",
@@ -29,12 +30,17 @@
2930
"INVALID_DATE_US_SHORT_BETWEEN": "Doit être un format de date valide (mm/dd/yy) OU (mm-dd-yy) entre {0} et {1}. ",
3031
"INVALID_DATE_US_SHORT_MAX": "Doit être une date valide (mm/dd/yy) OU (mm-dd-yy), égale ou inférieure à {0}. ",
3132
"INVALID_DATE_US_SHORT_MIN": "Doit être une date valide (mm/dd/yy) OU (mm-dd-yy), égale ou supérieure à {0}. ",
33+
"INVALID_DIGITS": "Doit être {0} chiffres. ",
34+
"INVALID_DIGITS_BETWEEN": "Doit être entre {0} et {1} chiffres. ",
3235
"INVALID_EMAIL": "Doit être une adresse courriel valide. ",
3336
"INVALID_EXACT_LEN": "Doit être d'une longueur fixe de {0} caractères. ",
37+
"INVALID_EXACT_NUM": "Doit être exactement {0}. ",
3438
"INVALID_FLOAT": "Doit être obligatoirement un nombre flottant positif (nombre entier exclu). ",
3539
"INVALID_FLOAT_SIGNED": "Doit être obligatoirement un nombre flottant positif ou négatif (nombre entier exclu). ",
3640
"INVALID_IBAN": "Doit être un IBAN valide. ",
37-
"INVALID_INPUT_MATCH": "Le champs de confirmation ne correspond pas au champs spécifié \"{0}\". ",
41+
"INVALID_IN_LIST": "Doit être un choix dans cette liste: ({0}). ",
42+
"INVALID_INPUT_DIFFERENT": "Le champ doit être différente du champ spécifié \"{1}\". ",
43+
"INVALID_INPUT_MATCH": "Le champ de confirmation ne correspond pas au champs spécifié \"{1}\". ",
3844
"INVALID_INTEGER": "Doit être un nombre entier positif. ",
3945
"INVALID_INTEGER_SIGNED": "Doit être un nombre entier positif ou négatif. ",
4046
"INVALID_IPV4": "Doit être un IP valide (IPV4). ",
@@ -45,6 +51,7 @@
4551
"INVALID_MAX_NUM": "Doit être une valeur numérique, égale ou inférieure à {0}. ",
4652
"INVALID_MIN_CHAR": "Doit avoir au moins {0} caractères. ",
4753
"INVALID_MIN_NUM": "Doit être une valeur numérique, égale ou supérieure à {0}. ",
54+
"INVALID_NOT_IN_LIST": "Doit être un choix en dehors de cette liste: ({0}). ",
4855
"INVALID_NUMERIC": "Doit être un nombre positif. ",
4956
"INVALID_NUMERIC_SIGNED": "Doit être un nombre positif ou négatif. ",
5057
"INVALID_PATTERN": "Doit suivre le format: {0}. ",
@@ -74,9 +81,11 @@
7481
"INPUT14": "Alphanumérique + Requis -- NG-DISABLED",
7582
"INPUT15": "Mot de Passe",
7683
"INPUT16": "Mot de Passe (Confirmation)",
77-
"INPUT17": "Alphanumérique + Exactement(3) + Requis -- debounce(3sec)",
78-
"INPUT18": "Date ISO (yyyy-mm-dd ) -- condition minimal >= 2001-01-01 ",
79-
"INPUT19": "Date US COURT (mm/dd/yy) -- entre les dates 12/01/99 et 12/31/15",
84+
"INPUT17": "Different Mot de Passe",
85+
"INPUT18": "Alphanumérique + Exactement(3) + Requis -- debounce(3sec)",
86+
"INPUT19": "Date ISO (yyyy-mm-dd ) -- condition minimal >= 2001-01-01 ",
87+
"INPUT20": "Date US COURT (mm/dd/yy) -- entre les dates 12/01/99 et 12/31/15",
88+
"INPUT21": "Choix dans cette liste (banana,orange,ice cream)",
8089
"FIRST_NAME": "Prénom",
8190
"LAST_NAME": "Nom de Famille",
8291
"RESET_FORM": "Réinitialisation le formulaire",

0 commit comments

Comments
 (0)