New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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
  • npm
  • Socket score

Version published
Weekly downloads
147
increased by2350%
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

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

    @Module({
      imports: [
        SchemaValidationModule,
      ],
      controllers: [],
      providers: [],
    })
    
  2. 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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc