Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
docs(ngPattern): add option of specifying literal RegExp
Browse files Browse the repository at this point in the history
Closes #15929
  • Loading branch information
Narretz committed Oct 11, 2017
1 parent d60d904 commit 8fb8d52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/ng/directive/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ var requiredDirective = function() {
* It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.
*
* The validator sets the `pattern` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
* does not match a RegExp which is obtained by evaluating the Angular expression given in the
* `ngPattern` attribute value:
* * If the expression evaluates to a RegExp object, then this is used directly.
* * If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
* does not match a RegExp which is obtained from the `ngPattern` attribute value:
* - the value is an AngularJS expression:
* - If the expression evaluates to a RegExp object, then this is used directly.
* - If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
* - If the value is a RegExp literal, e.g. `ngPattern="/^\d+$/"`, it is used directly.
*
* <div class="alert alert-info">
* **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to
Expand Down

0 comments on commit 8fb8d52

Please sign in to comment.