@@ -24,8 +24,8 @@ npm install construct-typed-parameters
24
24
import { TypedParameters } from ' construct-typed-parameters' ;
25
25
26
26
const parameters = new TypedParameters (parameterType => ({
27
- TOKEN: parameterType .String ({ required: true }),
28
- FIREBASE_CONFIG: parameterType .Json <{ apiKey: string }>({ required: true }),
27
+ TOKEN: parameterType .string ({ required: true }),
28
+ FIREBASE_CONFIG: parameterType .json <{ apiKey: string }>({ required: true }),
29
29
}));
30
30
31
31
const stringifiedParameters = parameters .stringify ({
@@ -104,41 +104,41 @@ see `test/index.spec.ts`.
104
104
import { TypedParameters } from ' construct-typed-parameters' ;
105
105
106
106
const parameters = new TypedParameters (pt => ({
107
- stringValue: pt .String ({
107
+ stringValue: pt .string ({
108
108
// required: boolean
109
109
required: true ,
110
110
// defaultValue?: T1
111
111
defaultValue: ' xxxx' ,
112
112
// validate?: (value: T1) => string | string[] | null;
113
113
validate : v => (v .includes (' x' ) ? null : ' the value must contain x' ),
114
114
}),
115
- unionStringValue: pt .UnionString <' v1' | ' v2' >({
115
+ unionStringValue: pt .unionString <' v1' | ' v2' >({
116
116
required: true ,
117
117
defaultValue: ' v1' ,
118
118
validate : v =>
119
119
[' v1' , ' v2' ].includes (v ) ? null : ' the value must be v1 or v2' ,
120
120
}),
121
- numberValue: pt .Number ({
121
+ numberValue: pt .number ({
122
122
required: true ,
123
123
defaultValue: 1 ,
124
124
validate : v => (v === 0 ? ' value must not be 0' : null ),
125
125
}),
126
- unionNumberValue: pt .UnionNumber < 0 | 1 > ({
126
+ unionNumberValue: pt .unionNumber < 0 | 1 > ({
127
127
required: true ,
128
128
defaultValue: 0 ,
129
129
validate : v => ([0 , 1 ].includes (v ) ? null : ' the value must be 0 or 1' ),
130
130
}),
131
- booleanValue: pt .Boolean ({
131
+ booleanValue: pt .boolean ({
132
132
required: true ,
133
133
defaultValue: true ,
134
134
validate : v => (v ? null : ' the value must be true' ),
135
135
}),
136
- jsonValue: pt .Json <{ apiKey: string }>({
136
+ jsonValue: pt .json <{ apiKey: string }>({
137
137
required: true ,
138
138
defaultValue: { apiKey: ' xxxx' },
139
139
validate : v => (v .apiKey .length ? null : ' apiKey must be specified' ),
140
140
}),
141
- arrayValue: pt .Json <string []>({
141
+ arrayValue: pt .json <string []>({
142
142
required: true ,
143
143
defaultValue: [' main' , ' sub' ],
144
144
validate : v => (v .length ? null : ' array must not empty' ),
0 commit comments