Removing Fields
Removing fields with schemafy.
The schemafy function in the Object Library gives two parameters for removing fields: one for removing invalid fields (default behavior) and one for removing any fields on a target object that are not defined on the schema object (not enabled by default).
However, one can always use the "removeField" function in the Object Library as well. Maybe for conditional removal or more involved use cases.
Remove Invalid Fields
Anytime a schema function has a boolean as the return type in the function signature, schemafy will interpret this to be a validation check instead of a new value to set. The default behavior is to remove values that return false (invalid).
You can return boolean values as a new, valid value (instead of a valid check) by setting the function signature return type to "unknown" instead of "bool". It is based on the type signature, not the returned value type.
To disable this functionality:
Remove Non-Schema Fields
Conditionally Remove Fields
Last updated
Was this helpful?