Skip to content

Small, lightweight and extensible Node.js library to validate/evaluate files (focused on use for config objects).

License

Notifications You must be signed in to change notification settings

peymanmortazavi/config-util

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NPM version Downloads

config-util

Small, lightweight and extensible Node.js library to validate/evaluate files (focused on use for config objects).

Installation

$ npm install config-util --save

Features

  • Object validation.
  • Get and set values by key path.
  • Easy way to define templates for object validation.
  • Compile the evaluation result so you'd get plain config object.

Quick Start

var configUtil = require('config-util');

Now you create your template object.

var template = {name: "string", formattedField: "string.regex(/Yes|No/)", age: "number.default(21)", emailInfo: {email: "string", username: "string.optional()", password: "string.optional()"}};

var evaluationResult = configUtil.evaluate(template, {name: "First Name"});
if(!evaluationResult.isValid) {
  console.log(JSON.stringify(evaluationResult.errors, null, 2));
} else {
  console.log(JSON.stringify(evaluationResult.compile(), null, 2));
}

About

Small, lightweight and extensible Node.js library to validate/evaluate files (focused on use for config objects).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published