🚦Validate Metadata
Step Three - Validate Metadata
Metadata is user-generated. Wallets have to confirm their correctness. Before performing any further action on metadata, wallets have to validate metadata.
What is JSON Schema? 🧐
JSON Schema is a JSON media type for defining the structure of the JSON data. JSON Schema provides a contract for what JSON data is required and how to interact with it.
JSON schemas can be created and used to validate received data against a predefined data model. There are many validator NPM packages available to validate metadata and provide the functionality to:
Generate Schema
Compile Schema
Validate received data for that particular schema
Zod NPM package is one of the validators used to validate JSON and object schema. The best thing about this package is that it has zero external dependencies involved.
Validator function to validate metadata against predefined schema generated using the Zod NPM package
Schema Created using Zod NPM package
Custom and Reusable Validator function to validate metadata
To Validate metadata, call the function by passing metadata.
Last updated