Replies: 1 comment
-
It seems like what you're looking for is defaultable properties: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a configuration object that I've loaded from JSON somewhere, and I want to validate/parse it into the correct format. However, in some situations, the configuration object may be missing certain paths, and I want to provide a fallback to load those paths from environment variables or similar. For example, I might have a schema looking roughly like this:
And I want the following cases to parse correctly:
I could handle this by having an ArkType parser with everything optional, and then constructing a new object based on the parsed value and any additional sources of information. But with ArkType, I like that I declare my types once and I don't need to duplicate the work. Is there a way to declare an ArkType parser that can fill in the blanks dynamically like this?
Beta Was this translation helpful? Give feedback.
All reactions