forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.validator.regexp.html
35 lines (34 loc) · 1.04 KB
/
angular.validator.regexp.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
<h1>angular.validator.regexp</h1>
<h2>Description</h2>
<p>Use regexp validator to restrict the input to any Regular Expression.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<input type="text" ng:validate="regexp:expression"/>
</tt>
<h3>In JavaScript</h3>
<tt ng:non-bindable>
angular.validator.regexp(value, expression);
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>value:string</tt>: value to validate</li>
<li><tt>expression:regexp</tt>: regular expression.</li>
</ul>
<h3>CSS</h3>
ng-validation-error
<h2>Example</h2>
<doc:example>
<doc:source>
Enter valid SSN:
<input name="ssn" value="123-45-6789" ng:validate="regexp:/^\d\d\d-\d\d-\d\d\d\d$/" >
</doc:source>
<doc:scenario>it('should invalidate non ssn', function(){
var textBox = element('.doc-example :input');
expect(textBox.attr('className')).not().toMatch(/ng-validation-error/);
expect(textBox.val()).toEqual('123-45-6789');
input('ssn').enter('123-45-67890');
expect(textBox.attr('className')).toMatch(/ng-validation-error/);
});
</doc:scenario>
</doc:example>