Skip to content

Commit 21bf62d

Browse files
authored
Merge pull request #2 from nighca/master
debug FormState `validated`
2 parents 791754d + ae86873 commit 21bf62d

16 files changed

+170
-90
lines changed

docs/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
Ƭ **FieldsArray**: *[ComposibleValidatable](interfaces/composiblevalidatable.md)‹any›[]*
4949

50-
*Defined in [formState.ts:9](https://github.com/qiniu/formstate-x/blob/f0b789c/src/formState.ts#L9)*
50+
*Defined in [formState.ts:9](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/formState.ts#L9)*
5151

5252
Mode: array
5353

@@ -57,7 +57,7 @@ ___
5757

5858
Ƭ **FieldsObject**: *object*
5959

60-
*Defined in [formState.ts:7](https://github.com/qiniu/formstate-x/blob/f0b789c/src/formState.ts#L7)*
60+
*Defined in [formState.ts:7](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/formState.ts#L7)*
6161

6262
Mode: object
6363

@@ -71,7 +71,7 @@ ___
7171

7272
Ƭ **ValidatableFields**: *[FieldsObject](README.md#fieldsobject) | [FieldsArray](README.md#fieldsarray)*
7373

74-
*Defined in [formState.ts:11](https://github.com/qiniu/formstate-x/blob/f0b789c/src/formState.ts#L11)*
74+
*Defined in [formState.ts:11](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/formState.ts#L11)*
7575

7676
Each key of the object is a validatable
7777

@@ -81,7 +81,7 @@ ___
8181

8282
Ƭ **Validated**: *object*
8383

84-
*Defined in [types.ts:16](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L16)*
84+
*Defined in [types.ts:16](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L16)*
8585

8686
#### Type declaration:
8787

@@ -91,7 +91,7 @@ ___
9191

9292
Ƭ **ValidationResponse**: *string | null | undefined | false*
9393

94-
*Defined in [types.ts:5](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L5)*
94+
*Defined in [types.ts:5](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L5)*
9595

9696
A truthy string or falsy values.
9797

@@ -101,7 +101,7 @@ ___
101101

102102
Ƭ **ValidatorResponse**: *[ValidationResponse](README.md#validationresponse) | Promise‹[ValidationResponse](README.md#validationresponse)*
103103

104-
*Defined in [types.ts:12](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L12)*
104+
*Defined in [types.ts:12](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L12)*
105105

106106
The return value of a validator.
107107

@@ -111,7 +111,7 @@ ___
111111

112112
Ƭ **ValueOf**: *State extends FormState<infer Fields, infer Fields extends { [key: string]: ComposibleValidatable<any, any>; } ? ValueOfObjectFields<infer Fields> : infer Fields extends (infer Field)[] ? ValueArrayOf<Field> : never> ? Fields extends { ...; } ? ValueOfObjectFields<...> : Fields extends (infer Field)[] ? ValueArrayOf...*
113113

114-
*Defined in [types.ts:90](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L90)*
114+
*Defined in [types.ts:91](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L91)*
115115

116116
Value of state (`FormState` or `FieldState`)
117117

@@ -121,7 +121,7 @@ ___
121121

122122
Ƭ **ValueOfArrayFields**: *Fields extends (infer Field)[] ? ValueArrayOf<Field> : never*
123123

124-
*Defined in [types.ts:76](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L76)*
124+
*Defined in [types.ts:77](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L77)*
125125

126126
Value of array-fields.
127127

@@ -131,7 +131,7 @@ ___
131131

132132
Ƭ **ValueOfFieldState**: *State extends FieldState<infer FieldType> ? FieldType : never*
133133

134-
*Defined in [types.ts:59](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L59)*
134+
*Defined in [types.ts:60](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L60)*
135135

136136
Value of `FieldState`.
137137

@@ -141,7 +141,7 @@ ___
141141

142142
Ƭ **ValueOfFields**: *Fields extends { [key: string]: ComposibleValidatable<any, any>; } ? ValueOfObjectFields<Fields> : Fields extends (infer Field)[] ? ValueArrayOf<Field> : never*
143143

144-
*Defined in [types.ts:83](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L83)*
144+
*Defined in [types.ts:84](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L84)*
145145

146146
Value of fields.
147147

@@ -151,7 +151,7 @@ ___
151151

152152
Ƭ **ValueOfObjectFields**: *object*
153153

154-
*Defined in [types.ts:71](https://github.com/qiniu/formstate-x/blob/f0b789c/src/types.ts#L71)*
154+
*Defined in [types.ts:72](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/types.ts#L72)*
155155

156156
Value of object-fields.
157157

@@ -163,7 +163,7 @@ Value of object-fields.
163163

164164
**bindInput**<**T**>(`state`: [FieldState](classes/fieldstate.md)‹T›): *[InputBindings](interfaces/inputbindings.md)‹T›*
165165

166-
*Defined in [bind.ts:16](https://github.com/qiniu/formstate-x/blob/f0b789c/src/bind.ts#L16)*
166+
*Defined in [bind.ts:16](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/bind.ts#L16)*
167167

168168
Helper method to bind state to your input component.
169169
You can define your own bindInput by specifying `getValue`.
@@ -182,7 +182,7 @@ Name | Type |
182182

183183
**bindInput**<**T**, **E**>(`state`: [FieldState](classes/fieldstate.md)‹T›, `getValue`: function): *[InputBindings](interfaces/inputbindings.md)‹T, E›*
184184

185-
*Defined in [bind.ts:17](https://github.com/qiniu/formstate-x/blob/f0b789c/src/bind.ts#L17)*
185+
*Defined in [bind.ts:17](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/bind.ts#L17)*
186186

187187
**Type parameters:**
188188

docs/classes/disposable.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Class that collects side-effects and dispose them on demand.
2828

2929
\+ **new Disposable**(): *[Disposable](disposable.md)*
3030

31-
*Defined in [disposable.ts:28](https://github.com/qiniu/formstate-x/blob/f0b789c/src/disposable.ts#L28)*
31+
*Defined in [disposable.ts:28](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/disposable.ts#L28)*
3232

3333
**Returns:** *[Disposable](disposable.md)*
3434

@@ -38,7 +38,7 @@ Class that collects side-effects and dispose them on demand.
3838

3939
**dispose**(): *void*
4040

41-
*Defined in [disposable.ts:23](https://github.com/qiniu/formstate-x/blob/f0b789c/src/disposable.ts#L23)*
41+
*Defined in [disposable.ts:23](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/disposable.ts#L23)*
4242

4343
Do dispose by calling all disposer functions.
4444

docs/classes/fieldstate.md

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ The state for a field.
4040
* [hasError](fieldstate.md#haserror)
4141
* [validated](fieldstate.md#validated)
4242
* [validating](fieldstate.md#validating)
43+
* [validationDisabled](fieldstate.md#validationdisabled)
4344

4445
### Methods
4546

@@ -60,7 +61,7 @@ The state for a field.
6061

6162
*Overrides [Disposable](disposable.md).[constructor](disposable.md#constructor)*
6263

63-
*Defined in [fieldState.ts:230](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L230)*
64+
*Defined in [fieldState.ts:235](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L235)*
6465

6566
**Parameters:**
6667

@@ -79,7 +80,7 @@ Name | Type | Default |
7980

8081
*Implementation of [ComposibleValidatable](../interfaces/composiblevalidatable.md).[$](../interfaces/composiblevalidatable.md#$)*
8182

82-
*Defined in [fieldState.ts:39](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L39)*
83+
*Defined in [fieldState.ts:39](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L39)*
8384

8485
Value that has bean validated with no error, AKA "safe".
8586

@@ -91,7 +92,7 @@ ___
9192

9293
*Implementation of [ComposibleValidatable](../interfaces/composiblevalidatable.md).[_activated](../interfaces/composiblevalidatable.md#_activated)*
9394

94-
*Defined in [fieldState.ts:15](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L15)*
95+
*Defined in [fieldState.ts:15](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L15)*
9596

9697
If activated (with auto validation).
9798
Field will only be activated when `validate()` or `onChange()` called.
@@ -102,7 +103,7 @@ ___
102103

103104
**_error**? : *undefined | string*
104105

105-
*Defined in [fieldState.ts:64](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L64)*
106+
*Defined in [fieldState.ts:64](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L64)*
106107

107108
The original error info of validation.
108109

@@ -114,7 +115,7 @@ ___
114115

115116
*Implementation of [ComposibleValidatable](../interfaces/composiblevalidatable.md).[_validateStatus](../interfaces/composiblevalidatable.md#_validatestatus)*
116117

117-
*Defined in [fieldState.ts:52](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L52)*
118+
*Defined in [fieldState.ts:52](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L52)*
118119

119120
The validate status.
120121

@@ -124,7 +125,7 @@ ___
124125

125126
**_value**: *TValue*
126127

127-
*Defined in [fieldState.ts:28](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L28)*
128+
*Defined in [fieldState.ts:28](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L28)*
128129

129130
Value that reacts to `onChange` immediately.
130131
You should only use it to bind with UI input componnet.
@@ -137,7 +138,7 @@ ___
137138

138139
*Implementation of [ComposibleValidatable](../interfaces/composiblevalidatable.md).[value](../interfaces/composiblevalidatable.md#value)*
139140

140-
*Defined in [fieldState.ts:34](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L34)*
141+
*Defined in [fieldState.ts:34](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L34)*
141142

142143
Value that can be consumed by your code.
143144
It's synced from `_value` with debounce of 200ms.
@@ -148,7 +149,7 @@ It's synced from `_value` with debounce of 200ms.
148149

149150
**get dirty**(): *boolean*
150151

151-
*Defined in [fieldState.ts:20](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L20)*
152+
*Defined in [fieldState.ts:20](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L20)*
152153

153154
If value has been touched (different with `initialValue`)
154155

@@ -160,7 +161,7 @@ ___
160161

161162
**get error**(): *undefined | string*
162163

163-
*Defined in [fieldState.ts:69](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L69)*
164+
*Defined in [fieldState.ts:69](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L69)*
164165

165166
The error info of validation.
166167

@@ -172,7 +173,7 @@ ___
172173

173174
**get hasError**(): *boolean*
174175

175-
*Defined in [fieldState.ts:76](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L76)*
176+
*Defined in [fieldState.ts:76](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L76)*
176177

177178
If the state contains error.
178179

@@ -184,7 +185,7 @@ ___
184185

185186
**get validated**(): *boolean*
186187

187-
*Defined in [fieldState.ts:84](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L84)*
188+
*Defined in [fieldState.ts:84](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L84)*
188189

189190
If the validation has been done.
190191
It does not means validation passed.
@@ -197,19 +198,31 @@ ___
197198

198199
**get validating**(): *boolean*
199200

200-
*Defined in [fieldState.ts:57](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L57)*
201+
*Defined in [fieldState.ts:57](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L57)*
201202

202203
If the state is doing a validation.
203204

204205
**Returns:** *boolean*
205206

207+
___
208+
209+
### validationDisabled
210+
211+
**get validationDisabled**(): *boolean*
212+
213+
*Defined in [fieldState.ts:197](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L197)*
214+
215+
If validation disabled.
216+
217+
**Returns:** *boolean*
218+
206219
## Methods
207220

208221
### disableValidationWhen
209222

210223
**disableValidationWhen**(`predict`: function): *this*
211224

212-
*Defined in [fieldState.ts:199](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L199)*
225+
*Defined in [fieldState.ts:204](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L204)*
213226

214227
Configure when to disable validation.
215228

@@ -229,7 +242,7 @@ ___
229242

230243
*Inherited from [Disposable](disposable.md).[dispose](disposable.md#dispose)*
231244

232-
*Defined in [disposable.ts:23](https://github.com/qiniu/formstate-x/blob/f0b789c/src/disposable.ts#L23)*
245+
*Defined in [disposable.ts:23](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/disposable.ts#L23)*
233246

234247
Do dispose by calling all disposer functions.
235248

@@ -241,7 +254,7 @@ ___
241254

242255
**onChange**(`value`: TValue): *void*
243256

244-
*Defined in [fieldState.ts:119](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L119)*
257+
*Defined in [fieldState.ts:119](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L119)*
245258

246259
Set `_value` on change event.
247260

@@ -259,7 +272,7 @@ ___
259272

260273
**reset**(): *void*
261274

262-
*Defined in [fieldState.ts:134](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L134)*
275+
*Defined in [fieldState.ts:134](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L134)*
263276

264277
Reset to initial status.
265278

@@ -271,7 +284,7 @@ ___
271284

272285
**set**(`value`: TValue): *void*
273286

274-
*Defined in [fieldState.ts:126](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L126)*
287+
*Defined in [fieldState.ts:126](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L126)*
275288

276289
Set `value` (& `_value`) synchronously.
277290

@@ -289,7 +302,7 @@ ___
289302

290303
**setError**(`error`: [ValidationResponse](../README.md#validationresponse)): *void*
291304

292-
*Defined in [fieldState.ts:91](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L91)*
305+
*Defined in [fieldState.ts:91](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L91)*
293306

294307
Set error info.
295308

@@ -309,7 +322,7 @@ ___
309322

310323
*Implementation of [ComposibleValidatable](../interfaces/composiblevalidatable.md)*
311324

312-
*Defined in [fieldState.ts:171](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L171)*
325+
*Defined in [fieldState.ts:171](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L171)*
313326

314327
Fire a validation behavior.
315328

@@ -321,7 +334,7 @@ ___
321334

322335
**validators**(...`validators`: [Validator](../interfaces/validator.md)‹TValue›[]): *this*
323336

324-
*Defined in [fieldState.ts:103](https://github.com/qiniu/formstate-x/blob/f0b789c/src/fieldState.ts#L103)*
337+
*Defined in [fieldState.ts:103](https://github.com/qiniu/formstate-x/blob/d29c1fc/src/fieldState.ts#L103)*
325338

326339
Add validator function.
327340

0 commit comments

Comments
 (0)