You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 1, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: changelog.txt
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -12,4 +12,6 @@ Angular-Validation change logs
12
12
1.3.8 (2015-03-15): Added between/min/max conditional validators on all Date types (ISO, EURO_LONG, EURO_SHORT, US_LONG, US_SHORT)
13
13
1.3.9 (2015-03-21): Added validation summary through 2 new and equivalent properties `$scope.$validationSummary` and `$scope.formName.$validationSummary`. Also added `bower` and `gulp` support, the Gulp script gives minified files.
14
14
1.3.10 (2015-03-28): Added new function of `checkFormValidity()` before submitting the form. Now use only 1 minified script instead of multiples.
15
-
1.3.11 (2015-03-30): Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
15
+
1.3.11 (2015-03-30): Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
16
+
1.3.12 (2015-04-04): Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
17
+
1.3.13 (2015-04-07) Fixed $translate delay issue when using external JSON files
Copy file name to clipboardExpand all lines: readme.md
+76-36Lines changed: 76 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
#Angular Validation (Directive / Service)
2
-
`Version: 1.3.11`
2
+
`Version: 1.3.13`
3
3
### Form validation after user inactivity of default 1sec. (customizable timeout)
4
4
5
5
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!
@@ -22,20 +22,21 @@ Huge rewrite to have a better code separation and also adding support to Service
22
22
23
23
<aname="index"></a>
24
24
## Index
25
-
*[Plunker Demo](#plunker)
26
-
*[Dependency](#dependencies)
25
+
*[Alternate Text on Validator](#alternate)
26
+
*[Available Validators](#validators)
27
+
*[Bootstrap Input Groups Wrapping - HOWTO](#input-groups-wrapping)
28
+
*[Changelog](#changelog)
29
+
*[Demo - Plunker](#plunker)
30
+
*[Dependencies](#dependencies)
31
+
*[Form Submit and Validation](#submit)
27
32
*[Install (bower)](#install)
28
33
*[Include it in your app project](#project)
34
+
*[Locales (languages)](#locales)
35
+
*[Regular Expressions (Regex)](#regex)
29
36
*[Requirements](#requirements)
30
37
*[Some Working Examples (Directive)](#examples-directive)
31
38
*[Some Working Examples (Service)](#examples-service)
32
-
*[Form Submit and Validation](#submit)
33
39
*[Validation summary](#validation-summary)
34
-
*[Bootstrap Input Groups Wrapping - HOWTO](#input-groups-wrapping)
35
-
*[Regular Expressions (Regex)](#regex)
36
-
*[Locales (languages)](#locales)
37
-
*[Available Validators](#validators)
38
-
*[Changelog](#changelog)
39
40
40
41
<aname="install"></a>
41
42
Install
@@ -177,8 +178,11 @@ P.S. For real live sample, see the [live demo](#plunker) or download the Github
177
178
178
179
// you can also remove a Validator with an ngClick or whichever way you prefer by calling .removeValidator()
Locales are simple sets of language defined in external JSON files, we can easily add any new language as extra files without affecting the behaviour of the angular directive. You could even change displayed language on the fly (note that the error message will be reflected only after field value is re-evaluated). Make sure to include the `angular-translate` library and configure it, see section [Include it in your Project](#project)
285
+
286
+
NOTE: To be fully localized, I should add the country code at the end of my JSON filename and then change the suffix on the `angular-translate``loader` method, but this would add an overhead and I prefer to keep it simple as validation messages often looks the same anyway (for example English from UK or US would most probably give similar error messages). If you really do want to be fully localized, then see the example in [Include it in your Project](#project)
287
+
288
+
```javascript
289
+
// define a key, could be on the fly with a button or a menu link
290
+
var key ='fr';
291
+
292
+
// change the translation language & reload the page to make sure all errors were rendered properly
293
+
$scope.switchLanguage=function (key) {
294
+
$translate.use(key).then(function() {
295
+
$route.reload();
296
+
});
297
+
};
298
+
```
299
+
*P.S. If you define a new Language set, please make a pull request and I would be happy to add them in current project... It would be nice to have Spanish, German or even Chinese :) Thank you.*
300
+
277
301
<aname="regex"></a>
278
302
Regular Expressions (Regex)
279
303
--------------------
@@ -294,44 +318,58 @@ Step #1-4 are for explanation only, at the end we show the full regex (make sure
294
318
295
319
Final code (without spaces): `regex:YYWW:=^(0[9]|1[0-9]|2[0-9]|3[0-9])(5[0-2]|[0-4][0-9])$:regex`
296
320
297
-
<aname="locales"></a>
298
-
Locales (languages)
321
+
<aname="alternate"></a>
322
+
Alternate Text on Validators
299
323
--------------------
300
-
Locales are simple sets of language defined in external JSON files, we can easily add any new language as extra files without affecting the behaviour of the angular directive. You could even change displayed language on the fly (note that the error message will be reflected only after field value is re-evaluated). Make sure to include the `angular-translate` library and configure it, see section [Include it in your Project](#project)
324
+
Validators can now use alternate text instead of the usual defined locale $translate text, for example seeing "Field is Required" on a `<select>` might not always be useful, it might be more useful to see an alternate text that is "Please choose an option". Alternate text works on all type of validators and is defined by adding `:alt=` at the end of any validators, it could be used on 1 or more validators directly inside the `validation=""` attribute. See the examples below.
325
+
```html
326
+
<!-- You can use translate in your HTML -->
327
+
<!-- Example #1 with 1 alternate text on 1 of the 2 validators -->
NOTE: To be fully localized, I should add the country code at the end of my JSON filename and then change the suffix on the `angular-translate``loader` method, but this would add an overhead and I prefer to keep it simple as validation messages often looks the same anyway (for example English from UK or US would most probably give similar error messages). If you really do want to be fully localized, then see the example in [Include it in your Project](#project)
330
+
<!-- Example #2, alternate text on multiple validators -->
331
+
<inputname="input1"validation="date_iso_between:2015-03-01,2015-03-30:alt=Booking date must be in April|required:alt=Booking Date is Required" />
332
+
333
+
<!-- Example #3, use $translate as alternate text -->
// Example #2, alternate text on multiple validators
345
+
myValidationService.addValidator('input1', 'date_iso_between:2015-03-01,2015-03-30:alt=Booking date must be in April|required:alt=Booking Date is Required');
*P.S. If you define a new Language set, please make a pull request and I would be happy to add them in current project... It would be nice to have Spanish, German or even Chinese :) Thank you.*
316
352
317
353
<aname="validators"></a>
318
354
Available Validators
319
355
--------------------
320
-
All validators are written as `snake_case` but it's up to the user's taste and could also be written as `camelCase`. So for example `alpha_dash_spaces` and `alphaDashSpaces` are both equivalent.
356
+
All validators are written as `snake_case` but it's up to the user's taste and could also be used as `camelCase`. So for example `alpha_dash_spaces` and `alphaDashSpaces` are both equivalent.
357
+
321
358
##### NOTE: on an `input type="number"`, the `+` sign is an invalid character (browser restriction) even if you are using a `signed` validator. If you really wish to use the `+`, then change your input to a `type="text"`.
359
+
322
360
*`alpha` Only alpha characters (including latin) are present (a-z, A-Z)
323
361
*`alpha_spaces` Only alpha characters (including latin) and spaces are present (a-z, A-Z)
324
362
*`alpha_num` Only alpha-numeric characters (including latin) are present (a-z, A-Z, 0-9)
325
363
*`alpha_num_spaces` Only alpha-numeric characters (with latin & spaces) are present (a-z, A-Z, 0-9)
326
364
*`alpha_dash` Only alpha-numeric characters + dashes, underscores are present (a-z, A-Z, 0-9, _-)
*`date_iso` Ensure date follows the ISO format (yyyy-mm-dd)
337
375
*`date_iso_between:d1,d2` Ensure date follows the ISO format and is between (d1) & (d2)
@@ -366,27 +404,27 @@ All validators are written as `snake_case` but it's up to the user's taste and c
366
404
*`ipv6` Check for valid IP (IPv6)
367
405
*`ipv6_hex` Check for valid IP (IPv6 Hexadecimal)
368
406
*`match:n` Match another input field(n), where (n) must be the exact ngModel attribute of input field to compare to.
369
-
*`match:n,t` Match another input field(n), same as (match:n) but also include (t) for alternative text to be displayed in the error message.
407
+
*`match:n,t` Match another input field(n), same as (match:n) but also include (t) for alternate input name to be displayed in the error message (it still uses default translated text, if you really wish to replace the complete text error, then use [:alt](#alternate))
370
408
*`max_date_iso` alias of `date_iso_max`.
371
-
*`min_date_iso` alias of `date_iso_min`.
372
409
*`max_date_euro_long` alias of `date_euro_long_max`.
373
-
*`min_date_euro_long` alias of `date_euro_long_min`.
374
410
*`max_date_euro_short` alias of `date_euro_short_max`.
375
-
*`min_date_euro_short` alias of `date_euro_short_min`.
376
411
*`max_date_us_long` alias of `date_us_long_max`.
377
-
*`min_date_us_long` alias of `date_us_long_min`.
378
412
*`max_date_us_short` alias of `date_us_short_max`.
379
-
*`min_date_us_short` alias of `date_us_short_min`.
380
413
*`max_len:n` Checks field length, no longer than specified length where (n) is length parameter.
381
414
*`max_num:n` Checks numeric value to be lower or equal than the number (n).
415
+
*`min_date_iso` alias of `date_iso_min`.
416
+
*`min_date_euro_long` alias of `date_euro_long_min`.
417
+
*`min_date_euro_short` alias of `date_euro_short_min`.
418
+
*`min_date_us_long` alias of `date_us_long_min`.
419
+
*`min_date_us_short` alias of `date_us_short_min`.
382
420
*`min_len:n` Checks field length, no shorter than specified length where (n) is length parameter.
383
421
*`min_num:n` Checks numeric value to be higher or equal than the number (n).
384
422
*`numeric` Only positive numeric value (float, integer).
385
423
*`numeric_signed` Only numeric value (float, integer) can also be signed (-/+).
386
424
*`regex` Ensure it follows a regular expression pattern... please see [Regex](#regex) section
387
425
*`required` Ensures the specified key value exists and is not empty
388
-
*`url` Check for valid URL or subdomain
389
426
*`time` Ensure time follows the format of (hh:mm) or (hh:mm:ss)
427
+
*`url` Check for valid URL or subdomain
390
428
391
429
<aname="dependencies"></a>
392
430
Dependencies
@@ -418,4 +456,6 @@ License
418
456
*[1.3.8](https://github.com/ghiscoding/angular-validation/commit/492d1060a91fb8b49fc70a0c7a1a581d904e0db0)`2015-03-15` Added between/min/max conditional validators on all Date types (iso, euro_long, euro_short, us_long, us_short)
419
457
*[1.3.9](https://github.com/ghiscoding/angular-validation/commit/931d3b04a00f0583612aefe28ad0bfcac326a38c)`2015-03-21` Added validation summary through 2 new and equivalent properties `$scope.$validationSummary` and `$scope.formName.$validationSummary`. Also added `bower` and `gulp` support, the Gulp script gives minified files.
420
458
*[1.3.10](https://github.com/ghiscoding/angular-validation/commit/18765a8dd986856a9fa176fc4835d90d25f663b2)`2015-03-29` Added new function of `checkFormValidity()` before submitting the form. Now use only 1 minified script instead of multiples.
421
-
*[1.3.11](https://github.com/ghiscoding/angular-validation/commit/e807584f0bcdf0f28ef2ef905b6bc4e890926ac1)`2015-03-30` Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
459
+
*[1.3.11](https://github.com/ghiscoding/angular-validation/commit/e807584f0bcdf0f28ef2ef905b6bc4e890926ac1)`2015-03-30` Accepted pull request #15 to fix form without name attribute. Also accepted pull request #18 to add Spanish locales.
460
+
*[1.3.12](https://github.com/ghiscoding/angular-validation/commit/0af82337a6961923e3b022a19660237d3e6f7184)`2015-04-04` Fix issue #16 and added Validators Alternate Text option on all type of validators. Also fixed removeValidator and clean a lot of code.
461
+
*[1.3.13](https://github.com/ghiscoding/angular-validation/commit/d0440bdd7fc2816e03d28ad3a9c3bd7bee8ac519)`2015-04-07` Fixed $translate delay issue when using external JSON files
0 commit comments