Remove property from existing schema #589
-
Hello, const UserSchema1 = Type.Strict(
Type.Object({
userId: Type.String({ format: 'uuid' }),
password: Type.String(),
}),
)
const UserSchema2 = Type.Omit(UserSchema1, ['password']) But if I console.log(UserSchema2.properties)
{
userId: { format: 'uuid', type: 'string' },
password: { type: 'string' }
} Am I missing something? Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@davideroffo Hi, Try removing Type.Strict from the outer schema. The Strict call actually removes compositing symbols that TypeBox needs to remap types. In most cases, you would only call strict on a schema if you are sure you've finished remapping the types, but more often than not, it should be fine to retain the symbols (as they do not serialize to Json are are compatible with Ajv and other validators) Hope this helps |
Beta Was this translation helpful? Give feedback.
@davideroffo Hi,
Try removing Type.Strict from the outer schema. The Strict call actually removes compositing symbols that TypeBox needs to remap types. In most cases, you would only call strict on a schema if you are sure you've finished remapping the types, but more often than not, it should be fine to retain the symbols (as they do not serialize to Json are are compatible with Ajv and other validators)
Hope this helps