Skip to content

Commit d28ae21

Browse files
committed
docs(validators): fix typos and make minor layout improvements
1 parent 8955cfb commit d28ae21

File tree

1 file changed

+78
-55
lines changed

1 file changed

+78
-55
lines changed

src/ng/directive/validators.js

+78-55
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @description
77
*
88
* ngRequired adds the required {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.
9-
* It is most often used for [@link input `input`} and {@link select `select`} controls, but can also be
9+
* It is most often used for {@link input `input`} and {@link select `select`} controls, but can also be
1010
* applied to custom controls.
1111
*
1212
* The directive sets the `required` attribute on the element if the Angular expression inside
@@ -43,16 +43,17 @@
4343
* </div>
4444
* </file>
4545
* <file name="protractor.js" type="protractor">
46-
* var required = element(by.binding('form.input.$error.required'));
47-
* var model = element(by.binding('model'));
48-
*
49-
* it('should set the required error', function() {
50-
* expect(required.getText()).toContain('true');
51-
*
52-
* element(by.id('input')).sendKeys('123');
53-
* expect(required.getText()).not.toContain('true');
54-
* expect(model.getText()).toContain('123');
55-
* });
46+
var required = element(by.binding('form.input.$error.required'));
47+
var model = element(by.binding('model'));
48+
var input = element(by.id('input'));
49+
50+
it('should set the required error', function() {
51+
expect(required.getText()).toContain('true');
52+
53+
input.sendKeys('123');
54+
expect(required.getText()).not.toContain('true');
55+
expect(model.getText()).toContain('123');
56+
});
5657
* </file>
5758
* </example>
5859
*/
@@ -82,14 +83,14 @@ var requiredDirective = function() {
8283
* @description
8384
*
8485
* ngPattern adds the pattern {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.
85-
* It is most often used for text-based [@link input `input`} controls, but can also be applied to custom text-based controls.
86+
* It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.
8687
*
87-
* The validator sets the `pattern` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
88-
* does not match a RegExp which is obtained by evaluating the Angular expression given in the
89-
* `ngPattern` attribute value:
90-
* * If the expression evaluates to a RegExp object, then this is used directly.
91-
* * If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
92-
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
88+
* The validator sets the `pattern` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
89+
* does not match a RegExp which is obtained by evaluating the Angular expression given in the
90+
* `ngPattern` attribute value:
91+
* * If the expression evaluates to a RegExp object, then this is used directly.
92+
* * If the expression evaluates to a string, then it will be converted to a RegExp after wrapping it
93+
* in `^` and `$` characters. For instance, `"abc"` will be converted to `new RegExp('^abc$')`.
9394
*
9495
* <div class="alert alert-info">
9596
* **Note:** Avoid using the `g` flag on the RegExp, as it will cause each successive search to
@@ -100,9 +101,16 @@ var requiredDirective = function() {
100101
* <div class="alert alert-info">
101102
* **Note:** This directive is also added when the plain `pattern` attribute is used, with two
102103
* differences:
103-
* 1. `ngPattern` does not set the `pattern` attribute and therefore not HTML5 constraint validation
104-
* is available.
105-
* 2. The `ngPattern` attribute must be an expression, while the `pattern` value must be interpolated
104+
* <ol>
105+
* <li>
106+
* `ngPattern` does not set the `pattern` attribute and therefore HTML5 constraint validation is
107+
* not available.
108+
* </li>
109+
* <li>
110+
* The `ngPattern` attribute must be an expression, while the `pattern` value must be
111+
* interpolated.
112+
* </li>
113+
* </ol>
106114
* </div>
107115
*
108116
* @example
@@ -128,18 +136,18 @@ var requiredDirective = function() {
128136
* </div>
129137
* </file>
130138
* <file name="protractor.js" type="protractor">
131-
var model = element(by.binding('model'));
132-
var input = element(by.id('input'));
139+
var model = element(by.binding('model'));
140+
var input = element(by.id('input'));
133141
134-
it('should validate the input with the default pattern', function() {
135-
input.sendKeys('aaa');
136-
expect(model.getText()).not.toContain('aaa');
142+
it('should validate the input with the default pattern', function() {
143+
input.sendKeys('aaa');
144+
expect(model.getText()).not.toContain('aaa');
137145
138-
input.clear().then(function() {
139-
input.sendKeys('123');
140-
expect(model.getText()).toContain('123');
141-
});
142-
});
146+
input.clear().then(function() {
147+
input.sendKeys('123');
148+
expect(model.getText()).toContain('123');
149+
});
150+
});
143151
* </file>
144152
* </example>
145153
*/
@@ -181,18 +189,25 @@ var patternDirective = function() {
181189
* @description
182190
*
183191
* ngMaxlength adds the maxlength {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.
184-
* It is most often used for text-based [@link input `input`} controls, but can also be applied to custom text-based controls.
192+
* It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.
185193
*
186-
* The validator sets the `maxlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
187-
* is longer than the integer obtained by evaluating the Angular expression given in the
188-
* `ngMaxlength` attribute value.
194+
* The validator sets the `maxlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
195+
* is longer than the integer obtained by evaluating the Angular expression given in the
196+
* `ngMaxlength` attribute value.
189197
*
190198
* <div class="alert alert-info">
191199
* **Note:** This directive is also added when the plain `maxlength` attribute is used, with two
192200
* differences:
193-
* 1. `ngMaxlength` does not set the `maxlength` attribute and therefore not HTML5 constraint validation
194-
* is available.
195-
* 2. The `ngMaxlength` attribute must be an expression, while the `maxlength` value must be interpolated
201+
* <ol>
202+
* <li>
203+
* `ngMaxlength` does not set the `maxlength` attribute and therefore HTML5 constraint
204+
* validation is not available.
205+
* </li>
206+
* <li>
207+
* The `ngMaxlength` attribute must be an expression, while the `maxlength` value must be
208+
* interpolated.
209+
* </li>
210+
* </ol>
196211
* </div>
197212
*
198213
* @example
@@ -218,7 +233,7 @@ var patternDirective = function() {
218233
* </div>
219234
* </file>
220235
* <file name="protractor.js" type="protractor">
221-
* var model = element(by.binding('model'));
236+
var model = element(by.binding('model'));
222237
var input = element(by.id('input'));
223238
224239
it('should validate the input with the default maxlength', function() {
@@ -260,18 +275,25 @@ var maxlengthDirective = function() {
260275
* @description
261276
*
262277
* ngMinlength adds the minlength {@link ngModel.NgModelController#$validators `validator`} to {@link ngModel `ngModel`}.
263-
* It is most often used for text-based [@link input `input`} controls, but can also be applied to custom text-based controls.
278+
* It is most often used for text-based {@link input `input`} controls, but can also be applied to custom text-based controls.
264279
*
265-
* The validator sets the `minlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
266-
* is shorter than the integer obtained by evaluating the Angular expression given in the
267-
* `ngMinlength` attribute value.
280+
* The validator sets the `minlength` error key if the {@link ngModel.NgModelController#$viewValue `ngModel.$viewValue`}
281+
* is shorter than the integer obtained by evaluating the Angular expression given in the
282+
* `ngMinlength` attribute value.
268283
*
269284
* <div class="alert alert-info">
270285
* **Note:** This directive is also added when the plain `minlength` attribute is used, with two
271286
* differences:
272-
* 1. `ngMinlength` does not set the `minlength` attribute and therefore not HTML5 constraint validation
273-
* is available.
274-
* 2. The `ngMinlength` value must be an expression, while the `minlength` value must be interpolated
287+
* <ol>
288+
* <li>
289+
* `ngMinlength` does not set the `minlength` attribute and therefore HTML5 constraint
290+
* validation is not available.
291+
* </li>
292+
* <li>
293+
* The `ngMinlength` value must be an expression, while the `minlength` value must be
294+
* interpolated.
295+
* </li>
296+
* </ol>
275297
* </div>
276298
*
277299
* @example
@@ -297,15 +319,16 @@ var maxlengthDirective = function() {
297319
* </div>
298320
* </file>
299321
* <file name="protractor.js" type="protractor">
300-
* var model = element(by.binding('model'));
301-
*
302-
* it('should validate the input with the default minlength', function() {
303-
* element(by.id('input')).sendKeys('ab');
304-
* expect(model.getText()).not.toContain('ab');
305-
*
306-
* element(by.id('input')).sendKeys('abc');
307-
* expect(model.getText()).toContain('abc');
308-
* });
322+
var model = element(by.binding('model'));
323+
var input = element(by.id('input'));
324+
325+
it('should validate the input with the default minlength', function() {
326+
input.sendKeys('ab');
327+
expect(model.getText()).not.toContain('ab');
328+
329+
input.sendKeys('abc');
330+
expect(model.getText()).toContain('abc');
331+
});
309332
* </file>
310333
* </example>
311334
*/

0 commit comments

Comments
 (0)