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

Allow Skipping Validation #10

Open
dflor003 opened this issue Oct 5, 2021 · 2 comments
Open

Allow Skipping Validation #10

dflor003 opened this issue Oct 5, 2021 · 2 comments

Comments

@dflor003
Copy link

dflor003 commented Oct 5, 2021

I have a use-case where I'm wrapping with my own library that integrates ts-convict and NestJS together to provide the foundation of config management for the rest of my NestJS libraries. So far we've been able to do this quite well with the existing implementation of ts-convict, but we are running into some interesting scenarios with exposing multiple configs based off the same config file but distributed independently in each library.

Let me explain a bit further with this example. Imagine our app is broken up into several modules (possibly in different, independently published NPM packages):

app.config.ts # Root app config
/logging
 - logging.config.ts # Expects to be configured under a "logging" sub-key
/auth
 - auth.config.ts # Expects to be configured under an "auth" sub-key
/metrics
 - metrics.config.ts # Expects to be configured under a "metrics" sub-key

We'd like to be able to have each of these libraries load its own subkey from the main config yml file which may look something like this:

appName: my-app
db:
  connectionString: someConnectionString

# Configures logging library
logging:
  logLevel: DEBUG

# Configures auth library
auth:
  issuer: ...

metrics:
  timeSeriesDbUri: ...

This works for us right now as long as we use the validationMethod: 'warn' option, but of course we get a bunch of warnings in our logs about the config file having fields out of sync with the config class since each sub config gets initialized independently. What are your thoughts on introducing a value to validationMethod that will allow it to skip validation altogether?

@alexreid801
Copy link

I love your feature! So much so that I have implemented this feature and opened a pull request.

You can view progress on the pull request here: #11

@kferrone
Copy link
Owner

kferrone commented Feb 6, 2022

I have approved the PR. I will bump the version here soon which will push to npm

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

No branches or pull requests

3 participants