Closed woody146 closed 3 months ago
@woody146 Hi,
The Convert
function only coerces data if a conversion is possible, but it doesn't subtract from the value, and doesn't remove additional properties. To remove excess properties, use the Clean
function which will remove any property or element from the value which doesn't have a exact definition derived from the schematic.
import { Clean, Convert } from '@sinclair/typebox/value'
function Process(schema: TSchema, value: unknown): unknown {
const converted = Convert(schema, value)
return Clean(schema, converted)
}
Hope this helps. Will close off the issue for now, but if you have any follow up questions, feel free to reply on this thread. Cheers! S
Current
Should add option (such as
strict
: boolean)