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

[Feature Request] check method to check if key exist or not #413

Open
Rstar1998 opened this issue Apr 4, 2023 · 0 comments
Open

[Feature Request] check method to check if key exist or not #413

Rstar1998 opened this issue Apr 4, 2023 · 0 comments

Comments

@Rstar1998
Copy link

Is it possible to provide a method which checks if a key or keypath exists or not , like in the example shown below ?

var convict = require("convict");
var config = convict({
  env: {
    doc: 'The application environment.',
    format: String,
    default: 'development',
    env: 'NODE_ENV'
  },
  ip: {
    doc: 'The IP address to bind.',
    format: String,
    default: '127.0.0.1',
    env: 'IP_ADDRESS',
  },
  port: {
    doc: 'The port to bind.',
    format: 'int',
    default: 8080,
    env: 'PORT',
    arg: 'port'
  }
});

config.get('ports'); // gives me error since its not in schema 
/*
can we have something like this ?
if (config.checkpath('ports')){

}
else
{

}
*/

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

1 participant