@@ -139,10 +139,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
139139 "'patternProperties' invalid options. Provide a valid map e.g. { '^fo.*$': S.string() }"
140140 )
141141 }
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
146144 } , { } )
147145 return setAttribute ( { schema, ...options } , [
148146 'patternProperties' ,
@@ -169,12 +167,10 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
169167 "'dependencies' invalid options. Provide a valid map e.g. { 'foo': ['bar'] } or { 'foo': S.string() }"
170168 )
171169 }
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
178174 } , { } )
179175 return setAttribute ( { schema, ...options } , [
180176 'dependencies' ,
@@ -199,10 +195,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
199195 "'dependentRequired' invalid options. Provide a valid array e.g. { 'foo': ['bar'] }"
200196 )
201197 }
202- return {
203- ...memo ,
204- [ prop ] : schema
205- }
198+ memo [ prop ] = schema
199+ return memo
206200 } , { } )
207201
208202 return setAttribute ( { schema, ...options } , [
@@ -228,10 +222,8 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
228222 )
229223 }
230224
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
235227 } , { } )
236228
237229 return setAttribute ( { schema, ...options } , [
@@ -309,12 +301,15 @@ const ObjectSchema = ({ schema = initialState, ...options } = {}) => {
309301 // strip undefined values or empty arrays or internals
310302 attributes = Object . entries ( { ...attributes , $id, type } ) . reduce (
311303 ( 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
318313 } ,
319314 { }
320315 )
0 commit comments