Table validation presenter for Unifig
Transforms configuration validation errors into clear table.
Table of Contents
Installation
npm i @unifig/validation-presenter-table
yarn add @unifig/validation-presenter-table
Quick Start
import { Config, PlainConfigAdapter } from '@unifig/core';
import { toTable } from '@unifig/validation-presenter-table';
function bootstrap() {
const validationError = Config.registerSync({
templates: [StorageOptions, NetworkOptions],
adapter: new PlainConfigAdapter({}),
});
if (validationError) {
console.error(toTable(validationError));
process.exit(1);
}
}
bootstrap();
Example output
āāāāāāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāā¬āāāāāāāāā¬āāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāā
ā Template ā Property ā Type ā Source ā Current Value ā Failed constraints ā
āāāāāāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāā¤
ā ā port ā Number ā PORT ā "not-a-port" ā isInt ā
ā āāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāā¤
ā TemplateMock ā db.url ā String ā DB_URL ā undefined ā isString ā
ā āāāāāāāāāāāāāāā¼āāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāā¼āāāāāāāāāāāāāāāāāāāāā¤
ā ā db.password ā String ā DB_PASSWORD ā undefined ā isString ā
āāāāāāāāāāāāāāāāāāāā“āāāāāāāāāāāāāā“āāāāāāāāā“āāāāāāāāāāāāāā“āāāāāāāāāāāāāāāā“āāāāāāāāāāāāāāāāāāāāā
Source
column presents where property value was taken from.
Example: from env variables in case of Env Adapter.
License
This project is licensed under the MIT License - see the LICENSE file for details.