feat: support named members in tuples

- Add NamedSchema interface with optional name property
- Update TupleSchema.elements to use NamedSchema[]
- Add parseNamedSchema() to support [x: number; y: number] syntax
- Update validator to parse named members in tuple values
- Fix schemaToTypeString in csv-loader for NamedSchema
- Fix createValidator to handle NamedSchema.schema
- Ensure single named element stays as tuple (not array)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
hyper
2026-03-31 16:36:32 +08:00
co-authored by Qwen-Coder
parent d056145462
commit 23ee60bc20
5 changed files with 77 additions and 29 deletions
+2 -2
View File
@@ -40,12 +40,12 @@ function schemaToTypeString(schema: Schema): string {
return 'boolean';
case 'array':
if (schema.element.type === 'tuple') {
const tupleElements = schema.element.elements.map(schemaToTypeString);
const tupleElements = schema.element.elements.map((el) => schemaToTypeString(el.schema));
return `[${tupleElements.join(', ')}]`;
}
return `${schemaToTypeString(schema.element)}[]`;
case 'tuple':
const tupleElements = schema.elements.map(schemaToTypeString);
const tupleElements = schema.elements.map((el) => schemaToTypeString(el.schema));
return `[${tupleElements.join(', ')}]`;
default:
return 'unknown';