forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.validator.integer.html
60 lines (56 loc) · 2.05 KB
/
angular.validator.integer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<h1>angular.validator.integer</h1>
<fieldset class="workInProgress">
<legend>Work In Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.
</fieldset>
<h2>Description</h2>
<p>Use number validator to restrict the input to integers with an
optional range. (See integer for whole numbers validator).</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<input type="text" ng:validate="integer<i>[:min]</i><i>[:max]</i>"/>
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
angular.validator.integer(value<i>[, min]</i><i>[, max]</i>);
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>value</tt> –
<tt>{string}</tt>
<tt></tt>
– value to validate</li>
<li><tt>min</tt> –
<tt>{int=}</tt>
<tt>[MIN_INT]</tt>
– minimum value.</li>
<li><tt>max</tt> –
<tt>{int=}</tt>
<tt>[MAX_INT]</tt>
– maximum value.</li>
</ul>
<h3>CSS</h3>
ng-validation-error
<h2>Example</h2>
<doc:example>
<doc:source>
Enter integer: <input name="n1" ng:validate="integer" > <br>
Enter integer equal or greater than 10: <input name="n2" ng:validate="integer:10" > <br>
Enter integer between 100 and 200 (inclusive): <input name="n3" ng:validate="integer:100:200" > <br>
</doc:source>
<doc:scenario>it('should invalidate integer', function(){
var n1 = element('.doc-example :input[name=n1]');
expect(n1.attr('className')).not().toMatch(/ng-validation-error/);
input('n1').enter('1.1');
expect(n1.attr('className')).toMatch(/ng-validation-error/);
var n2 = element('.doc-example :input[name=n2]');
expect(n2.attr('className')).not().toMatch(/ng-validation-error/);
input('n2').enter('10.1');
expect(n2.attr('className')).toMatch(/ng-validation-error/);
var n3 = element('.doc-example :input[name=n3]');
expect(n3.attr('className')).not().toMatch(/ng-validation-error/);
input('n3').enter('100.1');
expect(n3.attr('className')).toMatch(/ng-validation-error/);
});</doc:scenario>
</doc:example>