Socket
Socket
Sign inDemoInstall

@unifig/validation-presenter-json

Package Overview
Dependencies
7
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @unifig/validation-presenter-json

JSON validation presenter for unifig


Version published
Maintainers
1
Install size
5.53 kB
Created

Changelog

Source

1.0.2 (2023-07-18)

Bug Fixes

  • core: compatibility with next feature versions of typestack (1ab6d1c)

Readme

Source

JSON validation presenter for Unifig

Transforms configuration validation errors into json string.

JSON of contents

Installation

npm i @unifig/validation-presenter-json
# or
yarn add @unifig/validation-presenter-json

Quick Start

// main.ts
import { Config, PlainConfigAdapter } from '@unifig/core';
import { toJSON } from '@unifig/validation-presenter-json';

function bootstrap() {
  const validationError = Config.registerSync({
    templates: [StorageOptions, NetworkOptions],
    adapter: new PlainConfigAdapter({}),
  });
  if (validationError) {
    console.error(toJSON(validationError));
    process.exit(1);
  }
}

bootstrap();

Example output

[
  {
    "template": "TemplateMock",
    "errors": [
      {
        "property": "port",
        "type": "Number",
        "source": "PORT",
        "currentValue": "not-a-port",
        "failedConstraints": [{ "name": "isInt", "details": "port must be an integer number" }]
      },
      {
        "property": "db",
        "children": [
          {
            "property": "url",
            "type": "String",
            "source": "DB_URL",
            "failedConstraints": [{ "name": "isString", "details": "url must be a string" }]
          },
          {
            "property": "password",
            "type": "String",
            "source": "DB_PASSWORD",
            "failedConstraints": [{ "name": "isString", "details": "password must be a string" }]
          }
        ]
      }
    ]
  }
]

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

FAQs

Last updated on 18 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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