Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plugin config validation to ergomatic core #34

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

ross-weir
Copy link
Member

Allows plugins to specify a config schema which Ergomatic core will validate automatically.

Closes #25

Sorry for the formatting changes in this PR, not sure what changed 😄

@@ -45,4 +46,12 @@ export class ExamplePlugin extends Plugin<ExamplePluginConfig> {
}
}
}

// deno-lint-ignore no-explicit-any
configSchema(): z.ZodObject<any> | undefined {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about injecting z as a configSchema argument? I would even rename it to something else (s from schema?), so that if, in the future, we need to pivot from zod we can do it without much headaches.

The intention is not to wrap or abstract zod completely, but make it easer to replace if necessary, but no hard feelings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about injecting z as a configSchema argument? I would even rename it to something else (s from schema?), so that if, in the future, we need to pivot from zod we can do it without much headaches.

The intention is not to wrap or abstract zod completely, but make it easer to replace if necessary, but no hard feelings.

I like the intent but not sure how providing z as a arg would make it easier if it's not abstracted, are you able to provide a bit more detail here please?

I'll merge this PR for now and follow-up if we decide to go with providing z as a arg

@ross-weir ross-weir merged commit dcb6216 into main Sep 18, 2023
5 checks passed
@ross-weir ross-weir deleted the core-validate-plugin-configs branch September 18, 2023 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate plugin configs on their behalf
2 participants