fix: migrate resourceLocator validation to schema-driven approach (#304, #306)

- Replace hardcoded ['list', 'id', 'url'] modes with schema-based validation
- Read allowed modes from prop.typeOptions.resourceLocator.modes
- Support both object and array mode definition formats
- Add Google Sheets range/columns flexibility for v4+ nodes
- Implement Set node JSON structure validation
- Update tests to verify schema-based validation

Fixes #304 (Google Sheets "name" mode false positive)
Fixes #306 (Set node validation gaps)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-10-11 18:10:47 +02:00
parent dc62fd66cb
commit 43dea68f0b
4 changed files with 106 additions and 16 deletions

View File

@@ -678,7 +678,7 @@ describe('ConfigValidator - Basic Validation', () => {
expect(result.errors[0].fix).toContain('{ mode: "id", value: "gpt-4o-mini" }');
});
it('should reject invalid mode values', () => {
it('should reject invalid mode values when schema defines allowed modes', () => {
const nodeType = '@n8n/n8n-nodes-langchain.lmChatOpenAi';
const config = {
model: {
@@ -690,7 +690,16 @@ describe('ConfigValidator - Basic Validation', () => {
{
name: 'model',
type: 'resourceLocator',
required: true
required: true,
typeOptions: {
resourceLocator: {
modes: {
list: { displayName: 'List' },
id: { displayName: 'ID' },
url: { displayName: 'URL' }
}
}
}
}
];
@@ -700,7 +709,7 @@ describe('ConfigValidator - Basic Validation', () => {
expect(result.errors.some(e =>
e.property === 'model.mode' &&
e.type === 'invalid_value' &&
e.message.includes("must be 'list', 'id', or 'url'")
e.message.includes('must be one of [list, id, url]')
)).toBe(true);
});