const ConfigType1 = S.struct({
foo: S.string.pipe(S.optional),
bar: S.string.pipe(S.optional),
});
const ConfigType2 = S.struct({
baz: S.string,
});
const ConfigShema = S.struct({
config: S.union(ConfigType1, ConfigType2),
});
const configObj = {
config: {
baz: "123",
},
};
const parsed = S.parseEither(ConfigShema)(configObj);
// expected to have: {config: {baz: "123"}}
console.log(parsed.right); // --> but get: {config: {}}
const ConfigType1 = S.struct({
foo: S.string.pipe(S.optional),
bar: S.string.pipe(S.optional),
});
const ConfigType2 = S.struct({
baz: S.string,
});
const ConfigShema = S.struct({
config: S.union(ConfigType1, ConfigType2),
});
const configObj = {
config: {
baz: "123",
},
};
const parsed = S.parseEither(ConfigShema)(configObj);
// expected to have: {config: {baz: "123"}}
console.log(parsed.right); // --> but get: {config: {}}