Skip to content

Merge to support union schemas #299

Discussion options

You must be logged in to vote

Please try to use intersect for this use case. merge does only work for pure objects because it is able to truly merge objects together. For example, merge is able to overwrite individual entries.

const EnvSchema = intersect([
  union([DevSchema, ProdSchema]),
  object({
    // shared config
    FOO_BAR: string()
  }),
]);

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
2 replies
@fabian-hiller
Comment options

@fabian-hiller
Comment options

Comment options

You must be logged in to vote
5 replies
@indifferentghost
Comment options

@indifferentghost
Comment options

@fabian-hiller
Comment options

@fabian-hiller
Comment options

@indifferentghost
Comment options

Answer selected by indifferentghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants