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

Commit 6b68a16

Browse files
committed
typo
1 parent 0af8233 commit 6b68a16

File tree

1 file changed

+40
-9
lines changed

1 file changed

+40
-9
lines changed

readme.md

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Huge rewrite to have a better code separation and also adding support to Service
2222

2323
<a name="index"></a>
2424
## Index
25+
* [Alternate Text on Validator](#alternate)
2526
* [Available Validators](#validators)
2627
* [Bootstrap Input Groups Wrapping - HOWTO](#input-groups-wrapping)
2728
* [Changelog](#changelog)
@@ -317,13 +318,43 @@ Step #1-4 are for explanation only, at the end we show the full regex (make sure
317318

318319
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`
319320

321+
<a name="alternate"></a>
322+
Alternate Text on Validators
323+
--------------------
324+
Validators can now use alternate text instead of the usual defined locale $translate text, for example it could be useful to see a different text on a `<select>` instead of the usual "Field is Required". This 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 -->
328+
<input name="input1" validation="alpha|required:alt=Your Alternate Required Text." />
329+
330+
<!-- Example #2, alternate text on multiple validators -->
331+
<input name="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 -->
334+
<input name="input1" validation="min_len:5|required:alt={{ 'YOUR_TEXT' | translate }}" />
335+
```
336+
337+
```javascript
338+
// When using the Validation Service
339+
340+
myApp.controller('CtrlValidationService', function ($scope, $translate, validationService) {
341+
// Example #1 with 1 alternate text on 1 of the 2 validators
342+
myValidationService.addValidator('input1', 'alpha|required:alt=Your Alternate Required Text.');
343+
344+
// 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');
346+
347+
// Example #3, use $translate as alternate text
348+
// you can use the $translate.instant() function
349+
myValidationService.addValidator('input1', 'min_len:5|required:alt=' + $translate.instant('YOUR_TEXT'))
350+
});
351+
```
352+
320353
<a name="validators"></a>
321354
Available Validators
322355
--------------------
323356
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.
324357

325-
NEW Alternate Text: Validators can now use alternate text instead of the usual defined locale $translate text, for example it could be useful to see a different text on a `<select>` instead of the usual "Field is Required". This works on all type of validators and is defined by adding `:alt=` at the end of any validator and could be used on 1 validator or multiple validators. For example: `validation="required:alt=Your Alternate Required Text."` or `validation="date_iso_between:2015-03-01,2015-03-30:alt=Provide a Booking Date for April|required:Booking Date is Required"`. You could also use the `$translate` on the provided text, for example in the Directive you can use `validation="required: {{ 'YOUR_TEXT' | translate }}"` or in the Service you can use `....addValidator('input1', 'required:alt=' + $translate.instant('YOUR_TEXT'));`
326-
327358
##### 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"`.
328359

329360
* `alpha` Only alpha characters (including latin) are present (a-z, A-Z)
@@ -373,16 +404,16 @@ NEW Alternate Text: Validators can now use alternate text instead of the usual d
373404
* `ipv6` Check for valid IP (IPv6)
374405
* `ipv6_hex` Check for valid IP (IPv6 Hexadecimal)
375406
* `match:n` Match another input field(n), where (n) must be the exact ngModel attribute of input field to compare to.
376-
* `match:n,t` Match another input field(n), same as (match:n) but also include (t) for alternate text (this only replace the input name) 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))
377408
* `max_date_iso` alias of `date_iso_max`.
378-
* `min_date_iso` alias of `date_iso_min`.
379409
* `max_date_euro_long` alias of `date_euro_long_max`.
380-
* `min_date_euro_long` alias of `date_euro_long_min`.
381410
* `max_date_euro_short` alias of `date_euro_short_max`.
382-
* `min_date_euro_short` alias of `date_euro_short_min`.
383411
* `max_date_us_long` alias of `date_us_long_max`.
384-
* `min_date_us_long` alias of `date_us_long_min`.
385412
* `max_date_us_short` alias of `date_us_short_max`.
413+
* `min_date_iso` alias of `date_iso_min`.
414+
* `min_date_euro_long` alias of `date_euro_long_min`.
415+
* `min_date_euro_short` alias of `date_euro_short_min`.
416+
* `min_date_us_long` alias of `date_us_long_min`.
386417
* `min_date_us_short` alias of `date_us_short_min`.
387418
* `max_len:n` Checks field length, no longer than specified length where (n) is length parameter.
388419
* `max_num:n` Checks numeric value to be lower or equal than the number (n).
@@ -392,8 +423,8 @@ NEW Alternate Text: Validators can now use alternate text instead of the usual d
392423
* `numeric_signed` Only numeric value (float, integer) can also be signed (-/+).
393424
* `regex` Ensure it follows a regular expression pattern... please see [Regex](#regex) section
394425
* `required` Ensures the specified key value exists and is not empty
395-
* `url` Check for valid URL or subdomain
396426
* `time` Ensure time follows the format of (hh:mm) or (hh:mm:ss)
427+
* `url` Check for valid URL or subdomain
397428

398429
<a name="dependencies"></a>
399430
Dependencies
@@ -426,4 +457,4 @@ License
426457
* [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.
427458
* [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.
428459
* [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.
429-
* [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.
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.

0 commit comments

Comments
 (0)