Validate messages against AsyncAPI schemas (v2.0.0 and above). Supports loading schemas from local files or URLs in JSON/YAML format. Current stable version: 5.1.1. Provides class method fromSource() and instance method validate() for payload validation against channel operations. Distinguishes itself by supporting both 'publish'/'subscribe' and 'send'/'receive' operations, with support for message identifier keys. Includes deprecated validateByMessageId() method for older schemas. Actively maintained with TypeScript typings.
npm install asyncapi-validatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Loads an AsyncAPI YAML schema from file, creates a validator with message identifier option, and validates a payload for a given channel and operation.
Use .validate() with msgIdentifier option instead.
Provide msgIdentifier option when calling fromSource().
Use import AsyncApiValidator from 'asyncapi-validator' or const AsyncApiValidator = require('asyncapi-validator').defaultRefer to your AsyncAPI spec to determine correct operation value.
Change to import AsyncApiValidator from 'asyncapi-validator'
Add msgIdentifier: 'name' (or appropriate field) in fromSource options
Ensure payload contains all required fields defined in the AsyncAPI schema