@@ -139,10 +139,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
139
139
"'patternProperties' invalid options. Provide a valid map e.g. { '^fo.*$': S.string() }"
140
140
)
141
141
}
142
- return {
143
- ...memo ,
144
- [ pattern ] : omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' ] )
145
- }
142
+ memo [ pattern ] = omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' ] )
143
+ return memo
146
144
} , { } )
147
145
return setAttribute ( { schema, ...options } , [
148
146
'patternProperties' ,
@@ -169,12 +167,10 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
169
167
"'dependencies' invalid options. Provide a valid map e.g. { 'foo': ['bar'] } or { 'foo': S.string() }"
170
168
)
171
169
}
172
- return {
173
- ...memo ,
174
- [ prop ] : Array . isArray ( schema )
175
- ? schema
176
- : omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' , 'type' , 'definitions' ] )
177
- }
170
+ memo [ prop ] = Array . isArray ( schema )
171
+ ? schema
172
+ : omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' , 'type' , 'definitions' ] )
173
+ return memo
178
174
} , { } )
179
175
return setAttribute ( { schema, ...options } , [
180
176
'dependencies' ,
@@ -199,10 +195,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
199
195
"'dependentRequired' invalid options. Provide a valid array e.g. { 'foo': ['bar'] }"
200
196
)
201
197
}
202
- return {
203
- ...memo ,
204
- [ prop ] : schema
205
- }
198
+ memo [ prop ] = schema
199
+ return memo
206
200
} , { } )
207
201
208
202
return setAttribute ( { schema, ...options } , [
@@ -228,10 +222,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
228
222
)
229
223
}
230
224
231
- return {
232
- ...memo ,
233
- [ prop ] : omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' , 'type' , 'definitions' ] )
234
- }
225
+ memo [ prop ] = omit ( schema . valueOf ( { isRoot : false } ) , [ '$schema' , 'type' , 'definitions' ] )
226
+ return memo
235
227
} , { } )
236
228
237
229
return setAttribute ( { schema, ...options } , [
@@ -309,12 +301,15 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
309
301
// strip undefined values or empty arrays or internals
310
302
attributes = Object . entries ( { ...attributes , $id, type } ) . reduce (
311
303
( memo , [ key , value ] ) => {
312
- return key === '$schema' ||
313
- key === 'def' ||
314
- value === undefined ||
315
- ( Array . isArray ( value ) && value . length === 0 && key !== 'default' )
316
- ? memo
317
- : { ...memo , [ key ] : value }
304
+ if (
305
+ key !== '$schema' &&
306
+ key !== 'def' &&
307
+ value !== undefined &&
308
+ ! ( Array . isArray ( value ) && value . length === 0 && key !== 'default' )
309
+ ) {
310
+ memo [ key ] = value
311
+ }
312
+ return memo
318
313
} ,
319
314
{ }
320
315
)
0 commit comments