{"library":"protodef-validator","title":"ProtoDef Validator","description":"ProtoDef-validator is a Node.js library specifically engineered to validate protocol definitions structured using the ProtoDef schema language. It offers a programmatic interface for verifying that custom data types and complete protocol schemas adhere to established structural and semantic rules. Currently stable at version 1.4.0, the package demonstrates an active release cadence with minor updates and dependency bumps, indicating ongoing maintenance. Its core utility lies in preempting issues in protocol definition files by programmatically enforcing their correctness, a critical function for ensuring data integrity and compatibility in binary serialization and network communication. A key differentiator is its singular focus on validating the structural soundness of the schema itself, rather than performing data serialization or deserialization, thereby acting as a foundational tool for developers working within the ProtoDef ecosystem.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install protodef-validator"],"cli":null},"imports":["import { Validator } from 'protodef-validator';","const { Validator } = require('protodef-validator');","npm install -g protodef-validator\nprotodef-validator myProtocol.json"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Validator } from 'protodef-validator';\n\nconst validator = new Validator();\n\n// Add a custom type definition\nvalidator.addType('varint', ['pstring', { countType: 'i32' }]);\n\n// Define a simple protocol schema\nconst simpleProtocol = {\n  'main': [\n    {\n      'name': 'id',\n      'type': 'i32'\n    },\n    {\n      'name': 'value',\n      'type': 'varint'\n    },\n    {\n      'name': 'items',\n      'type': ['array', { countType: 'i32', type: 'pstring' }]\n    }\n  ]\n};\n\ntry {\n  // Validate the defined protocol\n  validator.validateProtocol(simpleProtocol);\n  console.log('Protocol validation successful!');\n\n  // Validate an individual type definition (e.g., 'varint')\n  validator.validateType(['pstring', { countType: 'i32' }]);\n  console.log('Individual type validation successful!');\n\n  // Example of an invalid type definition (will throw)\n  // validator.validateType(['nonExistentType']);\n\n} catch (error) {\n  console.error('Protocol validation failed:', error.message);\n}","lang":"javascript","description":"This quickstart demonstrates how to instantiate a Validator, add a custom type, define a simple protocol, and then validate both the custom type and the full protocol schema.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}