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

Commit ba92e07

Browse files
author
Kamil Kisiela
committed
refactor(inputs): apiCheck only type and step
At the moment it is impossible to check if min, max or step are being used only when type === 'number'.
1 parent dcf942f commit ba92e07

File tree

2 files changed

+2
-43
lines changed

2 files changed

+2
-43
lines changed

src/types/input/input.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import template from './input.html';
22
import { ngModelAttrsTransformer } from './../../helpers';
33

44
export default (formlyConfigProvider) => {
5-
function onlyNumberType(check) {
6-
return check.shape.onlyIf(['type'], check.oneOf(['number'])).optional;
7-
}
8-
95
formlyConfigProvider.setType({
106
template,
117
name: 'input',
@@ -23,9 +19,8 @@ export default (formlyConfigProvider) => {
2319
apiCheck: (check) => {
2420
return {
2521
templateOptions: {
26-
step: onlyNumberType(check),
27-
min: onlyNumberType(check),
28-
max: onlyNumberType(check)
22+
type: check.string,
23+
step: check.number.optional
2924
}
3025
};
3126
}

tests/types/input-spec.js

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ describe('formlyMaterial - input type', () => {
7878

7979
describe('number type specific', () => {
8080
describe('step attribute', () => {
81-
it('should fail on non number type', () => {
82-
expect(() => {
83-
compile({
84-
templateOptions: {
85-
type: 'text',
86-
step: 2
87-
},
88-
apiCheckFunction: 'throw'
89-
});
90-
}).toThrowError(Error, /step/i);
91-
});
92-
9381
it('should not be available on non number type', () => {
9482
compile({
9583
templateOptions: {
@@ -114,18 +102,6 @@ describe('formlyMaterial - input type', () => {
114102
});
115103

116104
describe('min attribute', () => {
117-
it('should fail on non number type', () => {
118-
expect(() => {
119-
compile({
120-
templateOptions: {
121-
type: 'text',
122-
min: 2
123-
},
124-
apiCheckFunction: 'throw'
125-
});
126-
}).toThrowError(Error, /min/i);
127-
});
128-
129105
it('should be available on number type', () => {
130106
compile({
131107
templateOptions: {
@@ -139,18 +115,6 @@ describe('formlyMaterial - input type', () => {
139115
});
140116

141117
describe('max attribute', () => {
142-
it('should fail on non number type', () => {
143-
expect(() => {
144-
compile({
145-
templateOptions: {
146-
type: 'text',
147-
max: 2
148-
},
149-
apiCheckFunction: 'throw'
150-
});
151-
}).toThrowError(Error, /max/i);
152-
});
153-
154118
it('should be available on number type', () => {
155119
compile({
156120
templateOptions: {

0 commit comments

Comments
 (0)