@unifig/validation-presenter-table
v1.1.3
Published
Table validation presenter for unifig
Downloads
13,050
Readme
Table validation presenter for Unifig
Transforms configuration validation errors into clear table.
Table of Contents
Installation
npm i @unifig/validation-presenter-table
# or
yarn add @unifig/validation-presenter-table
Quick Start
// main.ts
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.