-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Labels
Description
The Problem
Current message validation in rclnodejs is minimal:
- Cryptic errors - Publishing invalid messages results in generic "serialization failed" errors with no indication of what field or type is wrong
- Silent failures - Unknown fields are silently ignored, leading to hard-to-debug issues
- No schema introspection - No programmatic way to inspect message structure at runtime
Solution
Enhance message validation with:
1. Schema Introspection APIs
getMessageSchema(typeClass)- Get full schema for any message typegetFieldNames(typeClass)- List field namesgetFieldType(typeClass, fieldName)- Get type info for specific field
2. Validation Functions
validateMessage(obj, typeClass, options)- Returns{valid, issues[]}assertValidMessage(obj, typeClass, options)- Throws on invalidcreateMessageValidator(typeClass, options)- Reusable validator
3. Structured Error Reporting
- New
MessageValidationErrorclass with field-level issue details ValidationProblemenum:TYPE_MISMATCH,UNKNOWN_FIELD,MISSING_FIELD, etc.
4. Validation Options
strict: true- Error on unknown fieldscheckTypes: true- Validate field types- Nested message validation support