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:
@@ -18,6 +18,11 @@ const testCases = [
|
||||
{ schema: 'string', value: 'hello\\[world', description: 'Escaped bracket' },
|
||||
{ schema: 'string', value: 'hello\\\\world', description: 'Escaped backslash' },
|
||||
{ schema: '[string; string]', value: 'hello\\;world; test', description: 'Tuple with escaped semicolon' },
|
||||
{ schema: '[x: number; y: number]', value: '[x: 10; y: 20]', description: 'Named tuple' },
|
||||
{ schema: '[x: number; y: number]', value: 'x: 10; y: 20', description: 'Named tuple without brackets' },
|
||||
{ schema: '[name: string; age: number; active: boolean]', value: '[name: Alice; age: 30; active: true]', description: 'Named tuple with mixed types' },
|
||||
{ schema: '[name: string; age: number]', value: 'name: Bob; age: 25', description: 'Named tuple without brackets' },
|
||||
{ schema: '[point: [x: number; y: number]]', value: '[point: [x: 5; y: 10]]', description: 'Nested named tuple' },
|
||||
];
|
||||
|
||||
testCases.forEach(({ schema, value, description }) => {
|
||||
|
||||
Reference in New Issue
Block a user