Forcing Object Schema with Initialized Fields

Is there a way to force an object to be of a specified schema.
For example I would like that if a string field exist that it becomes initialized with empty strings.
// Expected type
{
    key1: string;
}


// Input: undefined.
// Output {key1: ""}

// Input {key2 : ""}
// Output {key2: "", key1: ""}
// Or event better Output {key1: ""} because key2 does not belong in the schema.


Maybe this isn't what schema is intended for, but this is a use case I've been trying to find a good solution for a long time.
Was this page helpful?