Socket
Book a DemoInstallSign in
Socket

@henkel_dx_ipaas/schema-validation-package

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@henkel_dx_ipaas/schema-validation-package

NestJs module with a caching layer for validating schemas taken from a schema registry API

0.0.6
latest
npmnpm
Version published
Weekly downloads
1
-91.67%
Maintainers
3
Weekly downloads
 
Created
Source

Schema Validation Package

Schema Validation Package is a simple NestJS package (module) that allows you to validate your data against a schema which is get from a Schema Registry API and cached locally.

Features

  • Validate incoming data against a schema. Uses AJV under the hood.
  • Get schema from a Schema Registry API.
  • Cache schema locally for faster access. It stores the cache entries for 5 minutes.

Getting Started

  • Add to your app.module.ts the following import:

    @Module({
      imports: [
        SchemaValidationModule,
      ],
      controllers: [],
      providers: [],
    })
    
  • In your services or guards, use the SchemaValidationService to validate your data against a schema.

How it works

The package is exposing a SchemaValidationModule which is a NestJS module that should be imported in your application. This module provides a SchemaValidationService which is a service that can be used to validate data against a schema.

SchemaValidationService exposes a single method called validateAgainstSchema with the following signature:

async validateAgainstSchema(schemaName: string, objectToValidate: unknown, schemaVersion?: string): { isValid: boolean, errors: Record<string, string> }

Required configuration

The package is using the following environment variables:

- SCHEMA_API_URL - URL of the Schema Registry API
- SCHEMA_API_SUBSCRIPTION_KEY - Subscription key for the Schema Registry API
- SCHEMA_VALIDATION_CACHE_TTL - TTL of the cached schema in milliseconds

FAQs

Package last updated on 20 May 2024

Did you know?

Socket

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.