Table validation presenter for unifig
npm install @unifig/validation-presenter-tableTransforms configuration validation errors into clear table.
- Installation
- Quick Start
- Example output
- License
``bash`
npm i @unifig/validation-presenter-tableor
yarn add @unifig/validation-presenter-table
`ts
// 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();
`
``
┌──────────────────┬─────────────┬────────┬─────────────┬───────────────┬────────────────────┐
│ 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.
This project is licensed under the MIT License - see the LICENSE file for details.