Skip to content

Commit c8d3498

Browse files
committed
docs(ngPattern): add option of specifying literal RegExp
Closes angular#15929
1 parent 2cb0318 commit c8d3498

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/ng/directive/validators.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ var requiredDirective = function() {
9696
* It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.
9797
*
9898
* The validator sets the `pattern` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
99-
* does not match a RegExp which is obtained by evaluating the AngularJS expression given in the
100-
* `ngPattern` attribute value:
101-
* * If the expression evaluates to a RegExp object, then this is used directly.
102-
* * If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
103-
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
99+
* does not match a RegExp which is obtained from the `ngPattern` attribute value:
100+
* - the value is an AngularJS expression:
101+
* - If the expression evaluates to a RegExp object, then this is used directly.
102+
* - If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
103+
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
104+
* - If the value is a RegExp literal, e.g. `ngPattern="/^\d+$/"`, it is used directly.
104105
*
105106
* <div class="alert alert-info">
106107
* **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to

0 commit comments

Comments
 (0)