Conditional Property Fallback in Schema Definition

How could I define that I first want to check a property for a string, and if it's not there, take it from another property?

So something like a combination of:

Schema.Struct({
    test: Schema.optionalWith(Schema.String, { exact: true }),
});

and
Schema.Struct({
    test: Schema.optionalWith(
        Schema.String,
        { exact: true },
    ).pipe(Schema.fromKey('test2')),
});


Where it's basically first check the property itself, if undefined check if there's a string in test2 and take it and if it's not there omit it?
Was this page helpful?