Socket
Socket
Sign inDemoInstall

centig

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.11 to 1.0.12

14

lib/centig.js

@@ -30,12 +30,14 @@ "use strict";

var throwErrorBeautifully = function (errors) {
var colorWarning = process.stdout.isTTY ? '\x1b[33;1m' : '';
var colorReset = process.stdout.isTTY ? '\x1b[0m' : '';
var isNodeJs = typeof window === 'undefined';
var colorWarning = isNodeJs ? '\x1b[33;1m' : '';
var colorReset = isNodeJs ? '\x1b[0m' : '';
var output = errors
.map(function (errorMessage) {
return colorWarning + "\u2718" + colorReset + " " + errorMessage;
.map(function (_a) {
var message = _a.message, path = _a.path;
return colorWarning + "\u2718" + colorReset + " " + message + " \n\n At path: " + path;
})
.join('\n');
throw Error('\n\n' + 'Validation Error \n' + output + '\n');
.join('\n\n\n');
throw Error('\n\n' + 'Centig Error \n\n' + output + '\n');
};
exports.default = centig;
//# sourceMappingURL=centig.js.map
import { ICentigBlock, ISupportedTypes, ISchema } from './centig';
declare const validateSchema: (configs: ISchema) => string[];
declare const validateCentigBlock: (name: string, centigBlock: ICentigBlock, validateTypeFn?: (value: any, type: ISupportedTypes, configName: string) => void) => void;
declare const typeCheckValue: (value: any, type: ISupportedTypes, configName: string) => void;
export interface IError {
path: string;
message: string;
}
declare const validateSchema: (configs: ISchema) => IError[];
declare const validateCentigBlock: (centigBlock: ICentigBlock, validateTypeFn?: (value: any, type: ISupportedTypes) => void) => void;
declare const typeCheckValue: (value: any, type: ISupportedTypes) => void;
export { validateSchema as default, typeCheckValue, validateCentigBlock };

@@ -30,5 +30,5 @@ "use strict";

}
validateCentigBlock(configName, configBlock);
validateCentigBlock(configBlock);
}
errors = __spreadArrays(errors, validateSchema(configBlock));
errors = __spreadArrays(errors, populateWithParentPath(validateSchema(configBlock), configName));
}

@@ -38,3 +38,3 @@ return;

catch (error) {
errors = __spreadArrays(errors, [error.message]);
errors = __spreadArrays(errors, [{ path: configName, message: error.message }]);
}

@@ -45,3 +45,12 @@ });

exports.default = validateSchema;
var validateCentigBlock = function (name, centigBlock, validateTypeFn) {
var populateWithParentPath = function (errors, configName) {
return errors.map(function (_a) {
var path = _a.path, message = _a.message;
return ({
message: message,
path: configName + '.' + path,
});
});
};
var validateCentigBlock = function (centigBlock, validateTypeFn) {
if (validateTypeFn === void 0) { validateTypeFn = typeCheckValue; }

@@ -57,3 +66,3 @@ var optional = centigBlock.optional, preprocess = centigBlock.preprocess, validate = centigBlock.validate, type = centigBlock.type, env = centigBlock.env, value = centigBlock.value;

}
throw Error("Missing " + (isAnEnvVarConfigBlock ? 'environment' : 'value') + " variable. Config name: " + name);
throw Error("Missing " + (isAnEnvVarConfigBlock ? 'environment' : 'value') + " variable " + (isAnEnvVarConfigBlock ? '"' + env + '"' : value) + ".");
}

@@ -63,3 +72,3 @@ var processedValue = null;

if (!utils_1.isFunction(preprocess)) {
throw Error('The preprocess value most by a function. Config name: ' + name);
throw Error('The value of preprocess most be of type function.');
}

@@ -70,3 +79,3 @@ processedValue = preprocess(valueToValidate);

if (!utils_1.isFunction(validate)) {
throw Error('The validate value most by a function. Config name: ' + name);
throw Error('The value of validate value most be of type function.');
}

@@ -76,7 +85,7 @@ validate(valueToValidate);

if (type) {
validateTypeFn(processedValue || valueToValidate, type, name);
validateTypeFn(processedValue || valueToValidate, type);
}
};
exports.validateCentigBlock = validateCentigBlock;
var typeCheckValue = function (value, type, configName) {
var typeCheckValue = function (value, type) {
if (!utils_1.isConstructor(type)) {

@@ -90,3 +99,3 @@ throw Error(type + ' is not a valid type');

if (!utils_1.isConstructorType(value, type)) {
throw Error(configName + ' is not of type ' + formattedTypeName);
throw Error((value || 'The value') + ' is not of type ' + formattedTypeName);
}

@@ -93,0 +102,0 @@ };

{
"name": "centig",
"version": "1.0.11",
"version": "1.0.12",
"description": "The Configuration Management library for your JavaScript application",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

# Centig
[![NPM version](https://img.shields.io/npm/v/centig.svg)](https://www.npmjs.org/package/centig)
[![size](https://badgen.net/bundlephobia/minzip/centig)](https://badgen.net/bundlephobia/minzip/centig)
[![Build Status](https://travis-ci.org/Alexloof/centig.svg?branch=master)](https://travis-ci.org/Alexloof/centig)

@@ -5,0 +6,0 @@ [![codecov](https://codecov.io/gh/Alexloof/centig/branch/master/graph/badge.svg)](https://codecov.io/gh/Alexloof/centig)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc