Skip to content

Commit 2d9f991

Browse files
committed
fix: zod validation crashes when some of fields don't have errors #636
fix #636
1 parent 6280f50 commit 2d9f991

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

CHANGELOG.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,174 @@
1+
# 6.9.4 (master)
2+
3+
- Fix: #636
4+
- Fix: Added `editable` props to initial props state.
5+
16
# 6.9.3 (master)
7+
28
- introduced `SubmitOptions` and `SubmitHooks` models.
39

410
# 6.9.2 (master)
11+
512
- deprecated `checkSVKValidationPlugin`
613

714
# 6.9.1 (master)
15+
816
- introduced `validate()` input types.
917
- introduced `ValidateOptions` & `ValidateOptionsInterface` models.
1018

1119
# 6.9.0 (master)
20+
1221
- Validator types improvements.
1322
- introduced `ValidationPlugin`, `ExtendPlugin` and `ValidationPluginConfig` models.
1423
- mandatory `package` prop when defining Validation Plugins.
1524
- deprecated `allowRequired` option (SVK).
1625
- Fix: `showErrors()` deep disabled when validating field.
1726

1827
# 6.8.3 (master)
28+
1929
- Fix: deprecated field `showAsyncErrors()`, use `showErrors()`.
2030
- FIx: field import in `FormInterface`
2131

2232
# 6.8.2 (master)
33+
2334
- Fix: call `invalidate()` with `deep` argument.
2435

2536
# 6.8.1 (master)
37+
2638
- Fix: call `invalidate()` with `async` argument.
2739

2840
# 6.8.0 (master)
41+
2942
- Field `invalidate()` methods arguments updated, introduced `deep`.
3043

3144
# 6.7.5 (master)
45+
3246
- better handling of `deep` argument for `showErrors()` & `invalidate()` methods.
3347
- removed `mixed` mode warning
3448

3549
# 6.7.4 (master)
50+
3651
- Fix: extend hooks and handlers on form instance using set()
3752

3853
# 6.7.3 (master)
54+
3955
- Fix: reset validation action for mobx strict mode
4056

4157
# 6.7.2 (master)
58+
4259
- Fix: mobx strict mode for hooks and handlers
4360

4461
# 6.7.1 (master)
62+
4563
- Fix: #632 observable hooks and handlers
4664

4765
# 6.7.0 (master)
66+
4867
- Feat: introduced `class`/`classes` props to handle `Field` extension in Fields Definitions.
4968

5069
# 6.6.1 (master)
70+
5171
- Fix: added missing bind method to field interface
5272

5373
# 6.6.0 (master)
74+
5475
- Introduced ZOD validation driver
5576
- Added SVK support for array of objects
5677
- Fix: #404
5778

5879
# 6.5.0 (master)
80+
5981
- Deprecatad: `setHooks()` & `getHooks()` methods.
6082
- Handle `set()/get()` for `hooks` and `handlers`
6183

6284
# 6.4.0 (master)
85+
6386
- Feat: ability to define or override hooks after initialization.
6487
- Feat: Introduced `setHooks()` & `getHooks()` methods.
6588

6689
# 6.3.7 (master)
90+
6791
- Fix: handle `onSubmit` hook return promise
6892

6993
# 6.3.6 (master)
94+
7095
- Fix: composer `error()` method.
7196
- Fix: default models/interfaces have now named exports.
7297
- Fix: check event w/ `isEvent()` to call `preventDefault()` for native support.
7398

7499
# 6.3.5 (master)
100+
75101
- Fix: `parseCheckArray` checks for `incremental` field status.
76102
- Updated `semantic-release`
77103

78104
# 6.3.4 (master)
105+
79106
- Fix: `isEmptyArray` reimplemented in `isArrayFromStruct` util function;
80107
- Removed lodash `_.isArray()` with `Array.isArray()`
81108
- Introduced `struct` prop in `makeField` method.
82109

83110
# 6.3.3 (master)
111+
84112
- Fix: `get('value')` retrieve empty array removed by `update()`
85113
- Fix: `composer` returned in `validate/submit` instead of single methods.
86114

87115
# 6.3.2 (master)
116+
88117
- Fix: `preserveDeletedFieldsValues` on `add()` action to handle `fields` prop.
89118

90119
# 6.3.1 (master)
120+
91121
- Introduced field `computed` prop. To handle nested array fields computed values.
92122

93123
# 6.3.0 (master)
124+
94125
- Introduced Forms Composer
95126
- Introduced Functional Computed Field Props
96127
- Introduced `strictSelect` and `strictSet` form options.
97128
- Form option `strictUpdate` behavior changed (now applied on `update()` action).
98129
- Field prop `validators` does not accept anymore a single function, an array of functions is needed.
99130

100131
# 6.2.3 (master)
132+
101133
- Introduced `applyInputConverterOnInit`, `applyInputConverterOnSet`, `applyInputConverterOnUpdate` form options.
102134
- Introduced `converter` function applied on `set value`.
103135
- Fix: `input` function removed from `set value`.
104136

105137
# 6.2.2 (master)
138+
106139
- Fix: mobx cycle detected in computation (get() strict mode)
107140

108141
# 6.2.1 (master) - DEPRECATED
142+
109143
- Refactored set value with input function
110144
- Deprecated input function on `initial` and `default` props.
111145
- Fix: input function applied 2 times when using `set()`
112146

113147
# 6.2.0 (master)
148+
114149
- Feat: #433 (File input append mode)
115150

116151
# 6.1.1 (master)
152+
117153
- Fix: #624 (defaults() helpers)
118154

119155
# 6.1.0 (master)
156+
120157
- Introduced `fallbackValue` and `retrieveNullifiedEmptyStrings` form options.
121158
- Fix: `get()` strict mode improved
122159
- Fix: default type file value;
123160

124161
# 6.0.0 (master)
162+
125163
- stable typescript release
126164

127165
# 5.10.1 (next)
166+
128167
- `set()` will apply `input` function also to `initial` and `default` props.
129168
- Fix: #519
130169

131170
# 5.10.0 (next)
171+
132172
- Introduced Field `trim()` method.
133173
- Introduced `validateTrimmedValue` form option.
134174
- Introduced `resetValidationBeforeValidate` form option.
@@ -138,6 +178,7 @@
138178
- Updated Issue: #283
139179

140180
# 5.9.1 (next)
181+
141182
- Fix: using `autoTrimValue` option will not trigger `onChange` Event Hook
142183

143184
# 5.9.0 (next)
@@ -181,7 +222,7 @@
181222
# 5.5.0 (next)
182223

183224
- Updated add()/del()/update() actions to handle `changed` field prop.
184-
(not triggering anymore `onChange` when using add(), use `onAdd`/`onDel` hooks instead).
225+
(not triggering anymore `onChange` when using add(), use `onAdd`/`onDel` hooks instead).
185226
- Updated `changed` computed prop behavior for nested fields and Event Hooks triggering.
186227
- Events Hooks now are triggered also from actions if not used Event Handlers.
187228
- fix: #585 #531
@@ -205,15 +246,19 @@ fix: #371 #399 #408
205246
# 5.3.2 (next)
206247

207248
- fix: Support `validatedWith` with nested property of a field's value
249+
208250
# 5.3.1 (next)
209251

210252
- fix: cannot change disabled prop on fields
253+
211254
# 5.3.0 (next)
212255

213256
- nested fields trigger onchange hook on container
257+
214258
# 5.2.0 (next)
215259

216260
- trigger onChange hook on add/del
261+
217262
# 5.1.0 (next)
218263

219264
- Form level onChange hook

src/State.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export default class State implements StateInterface {
6262

6363
initProps(initial: any = {}) {
6464
const initialProps: any = _.pick(initial, [
65+
...props.editable,
6566
...props.separated,
6667
...props.validation,
6768
...props.functions,
@@ -70,7 +71,7 @@ export default class State implements StateInterface {
7071

7172
this.set("initial", "props", initialProps);
7273

73-
const $unified :boolean = hasUnifiedProps(initial);
74+
const $unified: boolean = hasUnifiedProps(initial);
7475
const $separated: boolean = hasSeparatedProps(initial);
7576

7677
if (($separated || isArrayOfStrings(initial.fields)) && !$unified) {
@@ -137,31 +138,39 @@ export default class State implements StateInterface {
137138
key: OptionsEnum.validateOnChange,
138139
to: true,
139140
exec: () =>
140-
this.form.each((field: FieldInterface) => field.observeValidationOnChange()),
141+
this.form.each((field: FieldInterface) =>
142+
field.observeValidationOnChange()
143+
),
141144
},
142145
{
143146
// stop observing fields validateOnChange
144147
type: "update",
145148
key: OptionsEnum.validateOnChange,
146149
to: false,
147150
exec: () =>
148-
this.form.each((field: FieldInterface) => field.disposeValidationOnChange()),
151+
this.form.each((field: FieldInterface) =>
152+
field.disposeValidationOnChange()
153+
),
149154
},
150155
{
151156
// start observing fields validateOnBlur
152157
type: "update",
153158
key: OptionsEnum.validateOnBlur,
154159
to: true,
155160
exec: () =>
156-
this.form.each((field: FieldInterface) => field.observeValidationOnBlur()),
161+
this.form.each((field: FieldInterface) =>
162+
field.observeValidationOnBlur()
163+
),
157164
},
158165
{
159166
// stop observing fields validateOnBlur
160167
type: "update",
161168
key: OptionsEnum.validateOnBlur,
162169
to: false,
163170
exec: () =>
164-
this.form.each((field: FieldInterface) => field.disposeValidationOnBlur()),
171+
this.form.each((field: FieldInterface) =>
172+
field.disposeValidationOnBlur()
173+
),
165174
},
166175
])
167176
);

0 commit comments

Comments
 (0)