Skip to content

Commit

Permalink
Revision 0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Aug 1, 2023
1 parent 5a093bf commit 61efbc1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions examples/transform/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ function TNumber(schema: Types.TNumber, references: Types.TSchema[], value: any,
return Apply(schema, value, mode)
}
function TObject(schema: Types.TObject, references: Types.TSchema[], value: any, mode: ValueTransformMode) {
return Object.keys(schema.properties).reduce((acc, key) => {
return value[key] !== undefined ? { ...acc, [key]: Visit(schema.properties[key], references, value[key], mode) } : { ...acc }
}, value)
const transformed = Apply(schema, value, mode)
const properties = Object.keys(transformed).reduce((acc, key) => {
return key in schema.properties
? { ...acc, [key]: Visit(schema.properties[key], references, transformed[key], mode) }
: { ...acc, [key]: transformed[key] }
}, {})
return { ...properties }
}
function TPromise(schema: Types.TSchema, references: Types.TSchema[], value: any, mode: ValueTransformMode) {
return Apply(schema, value, mode)
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ License MIT
- [Types](#typesystem-types)
- [Formats](#typesystem-formats)
- [Policies](#typesystem-policies)
- [Transform](#Transform)
- [Transform](#transform)
- [Ecosystem](#ecosystem)
- [Benchmark](#benchmark)
- [Compile](#benchmark-compile)
Expand Down

0 comments on commit 61efbc1

Please sign in to comment.