Skip to content

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

Description

@Rstar1998

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
{

}
*/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions