Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit 8c246cf

Browse files
author
Kamil Kisiela
committed
feat(input): support for ngPattern
1 parent cce06e7 commit 8c246cf

File tree

4 files changed

+73
-50
lines changed

4 files changed

+73
-50
lines changed

CHANGELOG.md

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
Change Log
2-
==========
1+
# Change Log
32

43
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).
54

6-
[0.12.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.11.0...v0.12.0) - 2015-12-30
7-
---------------------------------------------------------------------------------------------------------------
5+
## [Unreleased](https://github.com/formly-js/angular-formly-templates-material/compare/v0.12.0...HEAD)
6+
7+
### Added
8+
9+
- (input) support for **ng-pattern** as **templateOptions.pattern** (#10)
10+
11+
## [0.12.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.11.0...v0.12.0) - 2015-12-30
812

913
### Added
1014

@@ -13,47 +17,41 @@ All notable changes to this project will be documented in this file. This projec
1317
- (input) support for **max** attribute of 'number' type (#6)
1418
- (input) support for **step** attribute of 'number' type (#6)
1519

16-
[0.11.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.10.0...v0.11.0) - 2015-12-18
17-
---------------------------------------------------------------------------------------------------------------
20+
## [0.11.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.10.0...v0.11.0) - 2015-12-18
1821

1922
### Added
2023

2124
- (chips) onAdd callback (equivalent to md-on-add)
2225
- (chips) onRemove callback (equivalent to md-on-remove)
2326
- (chips) onSelect callback (equivalent to md-on-select)
2427

25-
[0.10.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.9.0...v0.10.0) - 2015-12-17
26-
--------------------------------------------------------------------------------------------------------------
28+
## [0.10.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.9.0...v0.10.0) - 2015-12-17
2729

2830
### Added
2931

3032
- (textarea) **grow** option (equivalent to md-no-autogrow)
3133
- **divider** wrapper ([see documentation](docs/wrappers/divider.md)\)
3234

33-
[0.9.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.8.0...v0.9.0) - 2015-12-17
34-
------------------------------------------------------------------------------------------------------------
35+
## [0.9.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.8.0...v0.9.0) - 2015-12-17
3536

3637
### Added
3738

3839
- (select) **onClose** and **onOpen** options (equivalent to md-on-close and md-on-open)
3940

40-
[0.8.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.3...v0.8.0) - 2015-12-16
41-
------------------------------------------------------------------------------------------------------------
41+
## [0.8.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.3...v0.8.0) - 2015-12-16
4242

4343
### Changed
4444

4545
- BREAKING CHANGE: requires now **angular-material v1.0.0**
4646
- BREAKING CHANGE: for meteor package uses now **formly:angular-formly** instead of wieldo:angular-formly
4747

48-
[0.7.3](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.2...v0.7.3) - 2015-12-14
49-
------------------------------------------------------------------------------------------------------------
48+
## [0.7.3](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.2...v0.7.3) - 2015-12-14
5049

5150
### Changed
5251

5352
- Package name in AtmosphereJS (formly:angular-formly-templates-material)
5453

55-
[0.7.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.1...v0.7.2) - 2015-12-08
56-
------------------------------------------------------------------------------------------------------------
54+
## [0.7.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.1...v0.7.2) - 2015-12-08
5755

5856
### Added
5957

@@ -64,16 +62,14 @@ All notable changes to this project will be documented in this file. This projec
6462

6563
- Links to repository after transfer from wieldo to formly-js
6664

67-
[0.7.1](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.0...v0.7.1) - 2015-12-01
68-
------------------------------------------------------------------------------------------------------------
65+
## [0.7.1](https://github.com/formly-js/angular-formly-templates-material/compare/v0.7.0...v0.7.1) - 2015-12-01
6966

7067
### Changed
7168

7269
- use bound for datepicker's minDate, maxDate and filterDate instead of template manipulator
7370
- remove bound from slider's min, max and step attributes
7471

75-
[0.7.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.6.0...v0.7.0) - 2015-11-29
76-
------------------------------------------------------------------------------------------------------------
72+
## [0.7.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.6.0...v0.7.0) - 2015-11-29
7773

7874
### Added
7975

@@ -83,15 +79,13 @@ All notable changes to this project will be documented in this file. This projec
8379

8480
- Unit testing using karma instead of velocity (with coverage reports)
8581

86-
[0.6.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.2...v0.6.0) - 2015-11-27
87-
------------------------------------------------------------------------------------------------------------
82+
## [0.6.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.2...v0.6.0) - 2015-11-27
8883

8984
### Added
9085

9186
- compatibility with Meteor releases lower then 1.2
9287

93-
[0.5.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.1...v0.5.2) - 2015-11-19
94-
------------------------------------------------------------------------------------------------------------
88+
## [0.5.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.1...v0.5.2) - 2015-11-19
9589

9690
### Fixed
9791

@@ -106,23 +100,20 @@ All notable changes to this project will be documented in this file. This projec
106100
- deprecated **mdInputContainer** wrapper. Use **inputContainer**
107101
- deprecated **mdMessages** wrapper. Use **messages**
108102

109-
[0.5.1](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.0...v0.5.1) - 2015-11-18
110-
------------------------------------------------------------------------------------------------------------
103+
## [0.5.1](https://github.com/formly-js/angular-formly-templates-material/compare/v0.5.0...v0.5.1) - 2015-11-18
111104

112105
### Changed
113106

114107
- Refactor all files to use Strict Dependency Injection
115108

116-
[0.5.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.4.0...v0.5.0) - 2015-11-18
117-
------------------------------------------------------------------------------------------------------------
109+
## [0.5.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.4.0...v0.5.0) - 2015-11-18
118110

119111
### Added
120112

121113
- multiple support for select field
122114
- slider field with min, max, step and discrete options
123115

124-
[0.4.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.3.0...v0.4.0) - 2015-11-17
125-
------------------------------------------------------------------------------------------------------------
116+
## [0.4.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.3.0...v0.4.0) - 2015-11-17
126117

127118
### Added
128119

@@ -133,41 +124,36 @@ All notable changes to this project will be documented in this file. This projec
133124
- **mdInputContainer** wrapper. Use **inputContainer**
134125
- **mdMessages** wrapper. Use **messages**
135126

136-
[0.3.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.2.0...v0.3.0) - 2015-11-17
137-
------------------------------------------------------------------------------------------------------------
127+
## [0.3.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.2.0...v0.3.0) - 2015-11-17
138128

139129
### Added
140130

141131
- datepicker with date range and filtering *(currently in angular-material 1.0_RC4)*
142132
- Tests of formlyMaterial provider
143133

144-
[0.2.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.1.0...v0.2.0) - 2015-11-17
145-
------------------------------------------------------------------------------------------------------------
134+
## [0.2.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.1.0...v0.2.0) - 2015-11-17
146135

147136
### Added
148137

149138
- Support for textarea with cols and rows
150139
- ApiCheck for label, radio and select
151140
- Support for md-theme
152141

153-
[0.1.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.4...v0.1.0) - 2015-11-17
154-
------------------------------------------------------------------------------------------------------------
142+
## [0.1.0](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.4...v0.1.0) - 2015-11-17
155143

156144
### Added
157145

158146
- Support for md-select with valueProp and labelProp
159147
- Support for md-radio with valueProp and labelProp options
160148

161-
[0.0.4](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.3...v0.0.4) - 2015-11-13
162-
------------------------------------------------------------------------------------------------------------
149+
## [0.0.4](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.3...v0.0.4) - 2015-11-13
163150

164151
### Removed
165152

166153
- es5-shim package
167154
- standard-minifier package
168155

169-
[0.0.3](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.2...v0.0.3) - 2015-11-10
170-
------------------------------------------------------------------------------------------------------------
156+
## [0.0.3](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.2...v0.0.3) - 2015-11-10
171157

172158
### Fixed
173159

@@ -177,8 +163,7 @@ All notable changes to this project will be documented in this file. This projec
177163

178164
- Package name: wieldo:angular-formly-templates-material
179165

180-
[0.0.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.1...v0.0.2) - 2015-11-07
181-
------------------------------------------------------------------------------------------------------------
166+
## [0.0.2](https://github.com/formly-js/angular-formly-templates-material/compare/v0.0.1...v0.0.2) - 2015-11-07
182167

183168
### Fixed
184169

@@ -191,4 +176,4 @@ All notable changes to this project will be documented in this file. This projec
191176
- mdTheme to checkbox, switch
192177
- md-switch
193178

194-
0.0.1 - 2015-11-06 ------------------.
179+
## 0.0.1 - 2015-11-06

docs/types/input.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ Example
99

1010
```javascript
1111
{
12-
"type": "input",
13-
"key": "firstName",
14-
"templateOptions": {
15-
"type": "text",
16-
"label": "First name",
17-
"theme": "custom"
12+
type: "input",
13+
key: "firstName",
14+
templateOptions: {
15+
type: "text",
16+
label: "First name",
17+
pattern: "[a-zA-Z]+"
18+
theme: "custom"
1819
}
1920
}
2021
```
@@ -36,3 +37,7 @@ only if templateOptions.type is 'number'
3637
#### templateOptions.min *: number*
3738

3839
#### templateOptions.max *: number*
40+
41+
#### templateOptions.pattern *: string | RegExp*
42+
43+
Value of ng-pattern directive

src/types/input/input.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@ export default (formlyConfigProvider) => {
1313
ngModelAttrs: {
1414
mdMaxlength: {
1515
bound: 'md-maxlength'
16+
},
17+
pattern: {
18+
bound: 'ng-pattern'
1619
}
1720
}
1821
},
1922
apiCheck: (check) => {
2023
return {
2124
templateOptions: {
2225
type: check.string,
23-
step: check.number.optional
26+
step: check.number.optional,
27+
pattern: check.oneOfType([
28+
check.string,
29+
check.instanceOf(RegExp)
30+
]).optional
2431
}
2532
};
2633
}

tests/types/input-spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ describe('formlyMaterial - input type', () => {
7676
});
7777
});
7878

79+
describe('pattern', () => {
80+
it('should accept string', () => {
81+
const pattern = '[a-z]+';
82+
83+
compile({
84+
templateOptions: {
85+
pattern
86+
}
87+
});
88+
89+
expect(element.attr('ng-pattern')).toEqual(field.templateOptions.pattern);
90+
});
91+
92+
it('should accept RegExp', () => {
93+
const pattern = /[a-z]+/;
94+
95+
compile({
96+
templateOptions: {
97+
pattern
98+
}
99+
});
100+
101+
expect(element.attr('ng-pattern')).toEqual(`${field.templateOptions.pattern}`);
102+
});
103+
});
104+
79105
describe('number type specific', () => {
80106
describe('step attribute', () => {
81107
it('should not be available on non number type', () => {

0 commit comments

Comments
 (0)