@cdmx/n8n-nodes-schema-validator 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # n8n-nodes-schema-validator
2
+
3
+ [![npm version](https://badge.fury.io/js/n8n-nodes-schema-validator.svg)](https://www.npmjs.com/package/n8n-nodes-schema-validator)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Advanced JSON Schema validation node for [n8n](https://n8n.io/) workflows. Validate your data against JSON Schema standards with support for multiple schemas, format validation, and custom error messages.
7
+
8
+ ## Features
9
+
10
+ - ✅ **Single & Multiple Schema Validation** - Validate against one or multiple schemas per item
11
+ - 📧 **Format Validation** - Built-in support for email, URI, UUID, date, date-time, IPv4, IPv6, and more via [ajv-formats](https://github.com/ajv-validator/ajv-formats)
12
+ - 💬 **Custom Error Messages** - Define custom error messages in your schemas via [ajv-errors](https://github.com/ajv-validator/ajv-errors)
13
+ - 🔀 **Dual Output** - Valid items go to one output, invalid items go to another
14
+ - 🎯 **Data Path Extraction** - Validate specific parts of your data using JSON paths
15
+ - ⚙️ **Configurable Options** - Control strict mode, all errors collection, and more
16
+
17
+ ## Installation
18
+
19
+ ### Community Nodes Installation
20
+
21
+ 1. Go to **Settings** > **Community Nodes** in your n8n instance
22
+ 2. Select **Install**
23
+ 3. Enter `n8n-nodes-schema-validator` in the search field
24
+ 4. Click **Install**
25
+
26
+ ### Manual Installation
27
+
28
+ For self-hosted n8n instances:
29
+
30
+ ```bash
31
+ npm install n8n-nodes-schema-validator
32
+ ```
33
+
34
+ Then restart your n8n instance.
35
+
36
+ ## Usage
37
+
38
+ ### Single Schema Mode
39
+
40
+ Validate all incoming items against a single JSON schema:
41
+
42
+ ```json
43
+ {
44
+ "type": "object",
45
+ "properties": {
46
+ "name": { "type": "string", "minLength": 1 },
47
+ "email": { "type": "string", "format": "email" },
48
+ "age": { "type": "number", "minimum": 0 }
49
+ },
50
+ "required": ["name", "email"]
51
+ }
52
+ ```
53
+
54
+ ### Multiple Schemas Mode
55
+
56
+ Validate different parts of your data against different schemas:
57
+
58
+ 1. Set **Validation Mode** to "Multiple Schemas"
59
+ 2. Add multiple schema definitions
60
+ 3. For each schema, specify:
61
+ - **Schema Name**: A descriptive name for error messages
62
+ - **JSON Schema**: The validation schema
63
+ - **Data Path**: Optional path to extract data (e.g., `user.profile` or `items[0]`)
64
+
65
+ ### Match Modes
66
+
67
+ When using multiple schemas:
68
+ - **All Must Pass**: Item is valid only if ALL schemas pass
69
+ - **Any Must Pass**: Item is valid if ANY schema passes
70
+
71
+ ### Supported Formats
72
+
73
+ Thanks to ajv-formats, the following formats are supported:
74
+
75
+ - `email` - Email addresses
76
+ - `uri` / `url` - URIs and URLs
77
+ - `uuid` - UUIDs
78
+ - `date` - ISO 8601 dates (YYYY-MM-DD)
79
+ - `time` - ISO 8601 times
80
+ - `date-time` - ISO 8601 date-times
81
+ - `ipv4` / `ipv6` - IP addresses
82
+ - `hostname` - Hostnames
83
+ - `regex` - Regular expressions
84
+ - And more...
85
+
86
+ ### Custom Error Messages
87
+
88
+ Use ajv-errors syntax to define custom messages:
89
+
90
+ ```json
91
+ {
92
+ "type": "object",
93
+ "properties": {
94
+ "email": {
95
+ "type": "string",
96
+ "format": "email",
97
+ "errorMessage": {
98
+ "format": "Please provide a valid email address"
99
+ }
100
+ }
101
+ },
102
+ "required": ["email"],
103
+ "errorMessage": {
104
+ "required": {
105
+ "email": "Email address is required"
106
+ }
107
+ }
108
+ }
109
+ ```
110
+
111
+ ## Output
112
+
113
+ ### Valid Items (Output 1)
114
+ Items that pass validation are output unchanged.
115
+
116
+ ### Invalid Items (Output 2)
117
+ Items that fail validation include:
118
+ - `_validationMessage`: Human-readable error summary
119
+ - `_validationErrors` (single mode) or `_validationResults` (multiple mode): Detailed error information
120
+
121
+ ## Options
122
+
123
+ | Option | Default | Description |
124
+ |--------|---------|-------------|
125
+ | Enable Formats | `true` | Enable ajv-formats for format validation |
126
+ | Enable Custom Errors | `true` | Enable ajv-errors for custom messages |
127
+ | Strict Mode | `true` | Enable strict schema validation |
128
+ | All Errors | `true` | Collect all errors vs. stop at first |
129
+ | Include Error Details | `true` | Include detailed errors in output |
130
+
131
+ ## Development
132
+
133
+ ```bash
134
+ # Install dependencies
135
+ pnpm install
136
+
137
+ # Build the project
138
+ pnpm run build
139
+
140
+ # Run tests
141
+ pnpm test
142
+
143
+ # Run tests with coverage
144
+ pnpm test:coverage
145
+
146
+ # Lint code
147
+ pnpm run lint
148
+ ```
149
+
150
+ ## Resources
151
+
152
+ - [n8n Community Nodes Documentation](https://docs.n8n.io/integrations/#community-nodes)
153
+ - [JSON Schema Documentation](https://json-schema.org/)
154
+ - [AJV JSON Schema Validator](https://ajv.js.org/)
155
+ - [AJV Formats](https://github.com/ajv-validator/ajv-formats)
156
+ - [AJV Errors](https://github.com/ajv-validator/ajv-errors)
157
+
158
+ ## License
159
+
160
+ MIT
161
+
162
+ ## Contributing
163
+
164
+ Contributions are welcome! Please feel free to submit a Pull Request.
@@ -0,0 +1,5 @@
1
+ import type { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class SchemaValidator implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ }
@@ -0,0 +1,392 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaValidator = void 0;
4
+ const n8n_workflow_1 = require("n8n-workflow");
5
+ const lib_1 = require("./lib");
6
+ class SchemaValidator {
7
+ constructor() {
8
+ this.description = {
9
+ displayName: 'Schema Validator',
10
+ name: 'schemaValidator',
11
+ icon: 'file:SchemaValidator.svg',
12
+ group: ['transform'],
13
+ version: 1,
14
+ subtitle: '={{$parameter["validationMode"]}}',
15
+ description: 'Validates JSON data against JSON Schema with AJV, supporting formats and custom error messages',
16
+ defaults: {
17
+ name: 'Schema Validator',
18
+ },
19
+ inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
20
+ outputs: [n8n_workflow_1.NodeConnectionTypes.Main, n8n_workflow_1.NodeConnectionTypes.Main],
21
+ outputNames: ['Valid', 'Invalid'],
22
+ properties: [
23
+ {
24
+ displayName: 'Validation Mode',
25
+ name: 'validationMode',
26
+ type: 'options',
27
+ options: [
28
+ {
29
+ name: 'Single Schema',
30
+ value: 'single',
31
+ description: 'Validate all items against a single JSON schema',
32
+ },
33
+ {
34
+ name: 'Multiple Schemas',
35
+ value: 'multiple',
36
+ description: 'Validate items against multiple schemas with different configurations',
37
+ },
38
+ ],
39
+ default: 'single',
40
+ description: 'Choose validation mode',
41
+ },
42
+ {
43
+ displayName: 'JSON Schema',
44
+ name: 'jsonSchema',
45
+ type: 'json',
46
+ default: '{\n "type": "object",\n "properties": {\n "name": {\n "type": "string"\n },\n "email": {\n "type": "string",\n "format": "email"\n }\n },\n "required": ["name", "email"]\n}',
47
+ description: 'The JSON Schema to validate against. Supports Draft 7 and ajv-formats.',
48
+ required: true,
49
+ displayOptions: {
50
+ show: {
51
+ validationMode: ['single'],
52
+ },
53
+ },
54
+ },
55
+ {
56
+ displayName: 'Data Source',
57
+ name: 'dataSource',
58
+ type: 'options',
59
+ options: [
60
+ {
61
+ name: 'Input Data',
62
+ value: 'entireItem',
63
+ description: 'Validate the JSON data from the input',
64
+ },
65
+ {
66
+ name: 'Custom JSON',
67
+ value: 'customJson',
68
+ description: 'Validate custom JSON data (supports expressions)',
69
+ },
70
+ ],
71
+ default: 'entireItem',
72
+ description: 'What data to validate',
73
+ displayOptions: {
74
+ show: {
75
+ validationMode: ['single'],
76
+ },
77
+ },
78
+ },
79
+ {
80
+ displayName: 'Custom JSON',
81
+ name: 'customJson',
82
+ type: 'json',
83
+ default: '',
84
+ placeholder: '={{ $json }}',
85
+ description: 'Custom JSON data to validate (can use expressions)',
86
+ displayOptions: {
87
+ show: {
88
+ dataSource: ['customJson'],
89
+ validationMode: ['single'],
90
+ },
91
+ },
92
+ },
93
+ {
94
+ displayName: 'Schemas',
95
+ name: 'schemas',
96
+ type: 'fixedCollection',
97
+ typeOptions: {
98
+ multipleValues: true,
99
+ sortable: true,
100
+ },
101
+ default: {},
102
+ placeholder: 'Add Schema',
103
+ description: 'Define multiple schemas for validation',
104
+ displayOptions: {
105
+ show: {
106
+ validationMode: ['multiple'],
107
+ },
108
+ },
109
+ options: [
110
+ {
111
+ name: 'schemaItems',
112
+ displayName: 'Schema',
113
+ values: [
114
+ {
115
+ displayName: 'Schema Name',
116
+ name: 'schemaName',
117
+ type: 'string',
118
+ default: '',
119
+ placeholder: 'user-data',
120
+ description: 'A name to identify this schema in error messages',
121
+ required: true,
122
+ },
123
+ {
124
+ displayName: 'JSON Schema',
125
+ name: 'schema',
126
+ type: 'json',
127
+ default: '{\n "type": "object",\n "properties": {}\n}',
128
+ description: 'The JSON Schema definition',
129
+ required: true,
130
+ },
131
+ {
132
+ displayName: 'Data Path',
133
+ name: 'dataPath',
134
+ type: 'string',
135
+ default: '',
136
+ placeholder: 'data.user or leave empty for entire item',
137
+ description: 'JSON path to extract data from (e.g., "data.user" or "items[0]"). Leave empty to validate entire item.',
138
+ },
139
+ ],
140
+ },
141
+ ],
142
+ },
143
+ {
144
+ displayName: 'Match Mode',
145
+ name: 'matchMode',
146
+ type: 'options',
147
+ options: [
148
+ {
149
+ name: 'All Must Pass',
150
+ value: 'all',
151
+ description: 'Item is valid only if ALL schemas pass',
152
+ },
153
+ {
154
+ name: 'Any Must Pass',
155
+ value: 'any',
156
+ description: 'Item is valid if ANY schema passes',
157
+ },
158
+ ],
159
+ default: 'all',
160
+ description: 'How to combine multiple schema validations',
161
+ displayOptions: {
162
+ show: {
163
+ validationMode: ['multiple'],
164
+ },
165
+ },
166
+ },
167
+ {
168
+ displayName: 'Options',
169
+ name: 'options',
170
+ type: 'collection',
171
+ placeholder: 'Add Option',
172
+ default: {},
173
+ options: [
174
+ {
175
+ displayName: 'Enable Formats',
176
+ name: 'enableFormats',
177
+ type: 'boolean',
178
+ default: true,
179
+ description: 'Whether to enable ajv-formats for validating formats like email, uri, date, uuid, etc.',
180
+ },
181
+ {
182
+ displayName: 'Enable Custom Errors',
183
+ name: 'enableCustomErrors',
184
+ type: 'boolean',
185
+ default: true,
186
+ description: 'Whether to enable ajv-errors for custom error messages defined in schema',
187
+ },
188
+ {
189
+ displayName: 'Strict Mode',
190
+ name: 'strictMode',
191
+ type: 'boolean',
192
+ default: true,
193
+ description: 'Whether to enable strict schema validation',
194
+ },
195
+ {
196
+ displayName: 'All Errors',
197
+ name: 'allErrors',
198
+ type: 'boolean',
199
+ default: true,
200
+ description: 'Whether to collect all errors instead of stopping at first error',
201
+ },
202
+ {
203
+ displayName: 'Include Error Details',
204
+ name: 'includeErrorDetails',
205
+ type: 'boolean',
206
+ default: true,
207
+ description: 'Whether to include detailed error information in the output',
208
+ },
209
+ ],
210
+ },
211
+ ],
212
+ };
213
+ }
214
+ async execute() {
215
+ const items = this.getInputData();
216
+ const validItems = [];
217
+ const invalidItems = [];
218
+ const validationMode = this.getNodeParameter('validationMode', 0);
219
+ const options = this.getNodeParameter('options', 0, {});
220
+ const validatorOptions = {
221
+ allErrors: options.allErrors !== false,
222
+ strict: options.strictMode !== false,
223
+ verbose: true,
224
+ useFormats: options.enableFormats !== false,
225
+ useCustomErrors: options.enableCustomErrors !== false,
226
+ };
227
+ const ajv = (0, lib_1.createAjvInstance)(validatorOptions);
228
+ if (validationMode === 'single') {
229
+ executeSingleSchemaMode(this, items, validItems, invalidItems, ajv, options);
230
+ }
231
+ else {
232
+ executeMultipleSchemaMode(this, items, validItems, invalidItems, ajv, options);
233
+ }
234
+ return [validItems, invalidItems];
235
+ }
236
+ }
237
+ exports.SchemaValidator = SchemaValidator;
238
+ function executeSingleSchemaMode(context, items, validItems, invalidItems, ajv, options) {
239
+ const schemaJson = context.getNodeParameter('jsonSchema', 0);
240
+ const dataSource = context.getNodeParameter('dataSource', 0);
241
+ let schema;
242
+ try {
243
+ schema = (0, lib_1.parseSchema)(schemaJson);
244
+ const validationResult = (0, lib_1.isValidJsonSchema)(schema, ajv);
245
+ if (!validationResult.isValid) {
246
+ throw new Error(`Invalid JSON Schema: ${validationResult.error || 'Unknown error'}`);
247
+ }
248
+ }
249
+ catch (error) {
250
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), error);
251
+ }
252
+ const validator = (0, lib_1.createValidator)(schema, ajv);
253
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
254
+ const item = items[itemIndex];
255
+ try {
256
+ const customJsonParam = dataSource === 'customJson'
257
+ ? context.getNodeParameter('customJson', itemIndex)
258
+ : undefined;
259
+ const dataToValidate = (0, lib_1.extractDataToValidate)(item, dataSource, customJsonParam);
260
+ const result = (0, lib_1.validateData)(validator, dataToValidate);
261
+ if (result.isValid) {
262
+ validItems.push({
263
+ ...item,
264
+ pairedItem: itemIndex,
265
+ });
266
+ }
267
+ else {
268
+ const errorMessage = (0, lib_1.formatValidationErrorMessage)(result.errors);
269
+ const outputItem = {
270
+ json: {
271
+ ...item.json,
272
+ _validationErrors: options.includeErrorDetails !== false ? result.errors : undefined,
273
+ _validationMessage: errorMessage,
274
+ },
275
+ pairedItem: itemIndex,
276
+ };
277
+ if (item.binary) {
278
+ outputItem.binary = item.binary;
279
+ }
280
+ invalidItems.push(outputItem);
281
+ }
282
+ }
283
+ catch (error) {
284
+ const errorMessage = error instanceof Error ? error.message : String(error);
285
+ invalidItems.push({
286
+ json: {
287
+ ...item.json,
288
+ _validationErrors: [{ field: '/', message: errorMessage, keyword: 'parse', params: {} }],
289
+ _validationMessage: errorMessage,
290
+ },
291
+ pairedItem: itemIndex,
292
+ });
293
+ }
294
+ }
295
+ }
296
+ function executeMultipleSchemaMode(context, items, validItems, invalidItems, ajv, options) {
297
+ const schemasParam = context.getNodeParameter('schemas', 0);
298
+ const matchMode = context.getNodeParameter('matchMode', 0);
299
+ const schemas = schemasParam.schemaItems || [];
300
+ if (schemas.length === 0) {
301
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), 'At least one schema is required in multiple schemas mode');
302
+ }
303
+ const compiledSchemas = schemas.map((schemaItem, index) => {
304
+ try {
305
+ const schema = (0, lib_1.parseSchema)(schemaItem.schema);
306
+ const validationResult = (0, lib_1.isValidJsonSchema)(schema, ajv);
307
+ if (!validationResult.isValid) {
308
+ throw new Error(`Invalid JSON Schema "${schemaItem.schemaName || `Schema ${index + 1}`}": ${validationResult.error || 'Unknown error'}`);
309
+ }
310
+ return {
311
+ name: schemaItem.schemaName || `Schema ${index + 1}`,
312
+ validator: (0, lib_1.createValidator)(schema, ajv),
313
+ dataPath: schemaItem.dataPath || '',
314
+ };
315
+ }
316
+ catch (error) {
317
+ throw new n8n_workflow_1.NodeOperationError(context.getNode(), `Error compiling schema "${schemaItem.schemaName || `Schema ${index + 1}`}": ${error instanceof Error ? error.message : String(error)}`);
318
+ }
319
+ });
320
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
321
+ const item = items[itemIndex];
322
+ const schemaResults = [];
323
+ for (const compiledSchema of compiledSchemas) {
324
+ try {
325
+ let dataToValidate;
326
+ if (compiledSchema.dataPath) {
327
+ dataToValidate = (0, lib_1.extractDataFromPath)(item, compiledSchema.dataPath);
328
+ if (dataToValidate === undefined) {
329
+ schemaResults.push({
330
+ schemaName: compiledSchema.name,
331
+ isValid: false,
332
+ errors: [{
333
+ field: compiledSchema.dataPath,
334
+ message: `Path "${compiledSchema.dataPath}" not found in item`,
335
+ keyword: 'path',
336
+ params: { path: compiledSchema.dataPath },
337
+ }],
338
+ });
339
+ continue;
340
+ }
341
+ }
342
+ else {
343
+ dataToValidate = item.json;
344
+ }
345
+ const result = (0, lib_1.validateData)(compiledSchema.validator, dataToValidate);
346
+ schemaResults.push({
347
+ schemaName: compiledSchema.name,
348
+ isValid: result.isValid,
349
+ errors: result.errors,
350
+ });
351
+ }
352
+ catch (error) {
353
+ schemaResults.push({
354
+ schemaName: compiledSchema.name,
355
+ isValid: false,
356
+ errors: [{
357
+ field: '/',
358
+ message: error instanceof Error ? error.message : String(error),
359
+ keyword: 'parse',
360
+ params: {},
361
+ }],
362
+ });
363
+ }
364
+ }
365
+ const isItemValid = matchMode === 'all'
366
+ ? schemaResults.every(r => r.isValid)
367
+ : schemaResults.some(r => r.isValid);
368
+ if (isItemValid) {
369
+ validItems.push({
370
+ ...item,
371
+ pairedItem: itemIndex,
372
+ });
373
+ }
374
+ else {
375
+ const failedSchemas = schemaResults.filter(r => !r.isValid);
376
+ const errorMessages = failedSchemas.map(r => `[${r.schemaName}] ${(0, lib_1.formatValidationErrorMessage)(r.errors)}`).join('; ');
377
+ const outputItem = {
378
+ json: {
379
+ ...item.json,
380
+ _validationResults: options.includeErrorDetails !== false ? schemaResults : undefined,
381
+ _validationMessage: errorMessages,
382
+ },
383
+ pairedItem: itemIndex,
384
+ };
385
+ if (item.binary) {
386
+ outputItem.binary = item.binary;
387
+ }
388
+ invalidItems.push(outputItem);
389
+ }
390
+ }
391
+ }
392
+ //# sourceMappingURL=SchemaValidator.node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaValidator.node.js","sourceRoot":"","sources":["../../../nodes/SchemaValidator/SchemaValidator.node.ts"],"names":[],"mappings":";;;AAMA,+CAAuE;AAEvE,+BASe;AAGf,MAAa,eAAe;IAA5B;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,kBAAkB;YAC/B,IAAI,EAAE,iBAAiB;YACvB,IAAI,EAAE,0BAA0B;YAChC,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,mCAAmC;YAC7C,WAAW,EAAE,gGAAgG;YAC7G,QAAQ,EAAE;gBACT,IAAI,EAAE,kBAAkB;aACxB;YACD,MAAM,EAAE,CAAC,kCAAmB,CAAC,IAAI,CAAC;YAClC,OAAO,EAAE,CAAC,kCAAmB,CAAC,IA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ACrF,kBAAkB,EAAE,aAAa;iBACjC;gBACD,UAAU,EAAE,SAAS;aACrB,CAAC;YACF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBACjB,UAAU,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YACjC,CAAC;YACD,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -0,0 +1,13 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64">
2
+ <defs>
3
+ <linearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="100%">
4
+ <stop offset="0%" style="stop-color:#4CAF50;stop-opacity:1" />
5
+ <stop offset="100%" style="stop-color:#2E7D32;stop-opacity:1" />
6
+ </linearGradient>
7
+ </defs>
8
+ <rect x="4" y="4" width="56" height="56" rx="8" ry="8" fill="url(#grad1)"/>
9
+ <path d="M20 32 L28 40 L44 24" stroke="white" stroke-width="5" stroke-linecap="round" stroke-linejoin="round" fill="none"/>
10
+ <path d="M12 48 L22 48 M26 48 L36 48 M40 48 L50 48" stroke="white" stroke-width="2" stroke-linecap="round" opacity="0.7"/>
11
+ <circle cx="50" cy="14" r="6" fill="#FFC107"/>
12
+ <text x="50" y="17" text-anchor="middle" font-size="8" font-weight="bold" fill="#333">S</text>
13
+ </svg>
@@ -0,0 +1,5 @@
1
+ import type { INodeExecutionData } from 'n8n-workflow';
2
+ import type { DataSource } from '../types';
3
+ export declare function extractCustomJsonData(customJsonParam: string | object): unknown;
4
+ export declare function extractDataToValidate(item: INodeExecutionData, dataSource: DataSource, customJsonParam?: string | object): unknown;
5
+ export declare function extractDataFromPath(item: INodeExecutionData, path: string): unknown;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractCustomJsonData = extractCustomJsonData;
4
+ exports.extractDataToValidate = extractDataToValidate;
5
+ exports.extractDataFromPath = extractDataFromPath;
6
+ function extractCustomJsonData(customJsonParam) {
7
+ if (typeof customJsonParam === 'string') {
8
+ try {
9
+ return JSON.parse(customJsonParam);
10
+ }
11
+ catch (error) {
12
+ throw new Error(`Invalid custom JSON: ${error instanceof Error ? error.message : String(error)}`);
13
+ }
14
+ }
15
+ return customJsonParam;
16
+ }
17
+ function extractDataToValidate(item, dataSource, customJsonParam) {
18
+ if (dataSource === 'customJson') {
19
+ if (!customJsonParam) {
20
+ throw new Error('Custom JSON is required when Data Source is "Custom JSON"');
21
+ }
22
+ return extractCustomJsonData(customJsonParam);
23
+ }
24
+ return item.json;
25
+ }
26
+ function extractDataFromPath(item, path) {
27
+ const parts = path.split('.').flatMap(part => {
28
+ const arrayMatch = part.match(/^(\w+)\[(\d+)\]$/);
29
+ if (arrayMatch) {
30
+ return [arrayMatch[1], parseInt(arrayMatch[2], 10)];
31
+ }
32
+ return part;
33
+ });
34
+ let current = item.json;
35
+ for (const part of parts) {
36
+ if (current === null || current === undefined) {
37
+ return undefined;
38
+ }
39
+ if (typeof part === 'number') {
40
+ if (!Array.isArray(current)) {
41
+ return undefined;
42
+ }
43
+ current = current[part];
44
+ }
45
+ else {
46
+ if (typeof current !== 'object') {
47
+ return undefined;
48
+ }
49
+ current = current[part];
50
+ }
51
+ }
52
+ return current;
53
+ }
54
+ //# sourceMappingURL=dataExtractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataExtractor.js","sourceRoot":"","sources":["../../../../nodes/SchemaValidator/lib/dataExtractor.ts"],"names":[],"mappings":";;AASA,sDASC;AASD,sDAYC;AAQD,kDA4BC;AAlED,SAAgB,qBAAqB,CAAC,eAAgC;IACrE,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;QACzC,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACpC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,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YAClB,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACP,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;gBACjC,OAAO,SAAS,CAAC;YAClB,CAAC;YACD,OAAO,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createAjvInstance, isValidJsonSchema, createValidator, validateData, transformValidationErrors, formatValidationErrorMessage, getSupportedFormats } from './validator';
2
+ export { parseSchema, parseMultipleSchemas } from './schemaParser';
3
+ export { extractCustomJsonData, extractDataToValidate, extractDataFromPath } from './dataExtractor';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extractDataFromPath = exports.extractDataToValidate = exports.extractCustomJsonData = exports.parseMultipleSchemas = exports.parseSchema = exports.getSupportedFormats = exports.formatValidationErrorMessage = exports.transformValidationErrors = exports.validateData = exports.createValidator = exports.isValidJsonSchema = exports.createAjvInstance = void 0;
4
+ var validator_1 = require("./validator");
5
+ Object.defineProperty(exports, "createAjvInstance", { enumerable: true, get: function () { return validator_1.createAjvInstance; } });
6
+ Object.defineProperty(exports, "isValidJsonSchema", { enumerable: true, get: function () { return validator_1.isValidJsonSchema; } });
7
+ Object.defineProperty(exports, "createValidator", { enumerable: true, get: function () { return validator_1.createValidator; } });
8
+ Object.defineProperty(exports, "validateData", { enumerable: true, get: function () { return validator_1.validateData; } });
9
+ Object.defineProperty(exports, "transformValidationErrors", { enumerable: true, get: function () { return validator_1.transformValidationErrors; } });
10
+ Object.defineProperty(exports, "formatValidationErrorMessage", { enumerable: true, get: function () { return validator_1.formatValidationErrorMessage; } });
11
+ Object.defineProperty(exports, "getSupportedFormats", { enumerable: true, get: function () { return validator_1.getSupportedFormats; } });
12
+ var schemaParser_1 = require("./schemaParser");
13
+ Object.defineProperty(exports, "parseSchema", { enumerable: true, get: function () { return schemaParser_1.parseSchema; } });
14
+ Object.defineProperty(exports, "parseMultipleSchemas", { enumerable: true, get: function () { return schemaParser_1.parseMultipleSchemas; } });
15
+ var dataExtractor_1 = require("./dataExtractor");
16
+ Object.defineProperty(exports, "extractCustomJsonData", { enumerable: true, get: function () { return dataExtractor_1.extractCustomJsonData; } });
17
+ Object.defineProperty(exports, "extractDataToValidate", { enumerable: true, get: function () { return dataExtractor_1.extractDataToValidate; } });
18
+ Object.defineProperty(exports, "extractDataFromPath", { enumerable: true, get: function () { return dataExtractor_1.extractDataFromPath; } });
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/SchemaValidator/lib/index.ts"],"names":[],"mappings":";;;AAAA,yCAQqB;AAPpB,8GAAA,iBAAiB,OAAA;AACjB,8GAAA,iBAAiB,OAAA;AACjB,4GAAA,eAAe,OAAA;AACf,yGAAA,YAAY,OAAA;AACZ,sHAAA,yBAAyB,OAAA;AACzB,yHAAA,4BAA4B,OAAA;AAC5B,gHAAA,mBAAmB,OAAA;AAEpB,+CAAmE;AAA1D,2GAAA,WAAW,OAAA;AAAE,oHAAA,oBAAoB,OAAA;AAC1C,iDAAoG;AAA3F,sHAAA,qBAAqB,OAAA;AAAE,sHAAA,qBAAqB,OAAA;AAAE,oHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function parseSchema(schemaJson: string | object): object;
2
+ export declare function parseMultipleSchemas(schemasJson: string | object[]): object[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseSchema = parseSchema;
4
+ exports.parseMultipleSchemas = parseMultipleSchemas;
5
+ function parseSchema(schemaJson) {
6
+ if (typeof schemaJson === 'string') {
7
+ try {
8
+ return JSON.parse(schemaJson);
9
+ }
10
+ catch (error) {
11
+ throw new Error(`Invalid JSON schema format: ${error instanceof Error ? error.message : String(error)}`);
12
+ }
13
+ }
14
+ return schemaJson;
15
+ }
16
+ function parseMultipleSchemas(schemasJson) {
17
+ if (typeof schemasJson === 'string') {
18
+ try {
19
+ const parsed = JSON.parse(schemasJson);
20
+ if (!Array.isArray(parsed)) {
21
+ throw new Error('Expected an array of schemas');
22
+ }
23
+ return parsed;
24
+ }
25
+ catch (error) {
26
+ throw new Error(`Invalid schemas format: ${error instanceof Error ? error.message : String(error)}`);
27
+ }
28
+ }
29
+ return schemasJson;
30
+ }
31
+ //# sourceMappingURL=schemaParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaParser.js","sourceRoot":"","sources":["../../../../nodes/SchemaValidator/lib/schemaParser.ts"],"names":[],"mappings":";;AAMA,kCASC;AAQD,oDAaC;AA9BD,SAAgB,WAAW,CAAC,UAA2B;IACtD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACpC,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,+BAA+B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC1G,CAAC;IACF,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAQD,SAAgB,oBAAoB,CAAC,WAA8B;IAClE,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE,CAAC;QACrC,IAAI,CAAC;YACJ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YACvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YACjD,CAAC;YACD,OAAO,MAAM,CAAC;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,2BAA2B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACtG,CAAC;IACF,CAAC;IACD,OAAO,WAAW,CAAC;AACpB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import Ajv, { type ValidateFunction } from 'ajv';
2
+ import type { ValidationError, ValidationResult, ValidatorOptions } from '../types';
3
+ export declare function createAjvInstance(options: ValidatorOptions): Ajv;
4
+ export declare function isValidJsonSchema(schema: object, ajvInstance?: Ajv): {
5
+ isValid: boolean;
6
+ error?: string;
7
+ };
8
+ export declare function createValidator(schema: object, ajvInstance?: Ajv): ValidateFunction;
9
+ export declare function transformValidationErrors(validator: ValidateFunction): ValidationError[];
10
+ export declare function validateData(validator: ValidateFunction, data: unknown): ValidationResult;
11
+ export declare function formatValidationErrorMessage(errors: ValidationError[]): string;
12
+ export declare function getSupportedFormats(): string[];
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createAjvInstance = createAjvInstance;
7
+ exports.isValidJsonSchema = isValidJsonSchema;
8
+ exports.createValidator = createValidator;
9
+ exports.transformValidationErrors = transformValidationErrors;
10
+ exports.validateData = validateData;
11
+ exports.formatValidationErrorMessage = formatValidationErrorMessage;
12
+ exports.getSupportedFormats = getSupportedFormats;
13
+ const ajv_1 = __importDefault(require("ajv"));
14
+ const ajv_formats_1 = __importDefault(require("ajv-formats"));
15
+ const ajv_errors_1 = __importDefault(require("ajv-errors"));
16
+ function createAjvInstance(options) {
17
+ const ajvOptions = {
18
+ allErrors: options.allErrors,
19
+ strict: options.strict,
20
+ verbose: options.verbose,
21
+ };
22
+ const ajv = new ajv_1.default(ajvOptions);
23
+ if (options.useFormats) {
24
+ (0, ajv_formats_1.default)(ajv);
25
+ }
26
+ if (options.useCustomErrors) {
27
+ (0, ajv_errors_1.default)(ajv);
28
+ }
29
+ return ajv;
30
+ }
31
+ const defaultAjv = createAjvInstance({
32
+ allErrors: true,
33
+ strict: true,
34
+ verbose: true,
35
+ useFormats: true,
36
+ useCustomErrors: true,
37
+ });
38
+ function isValidJsonSchema(schema, ajvInstance = defaultAjv) {
39
+ try {
40
+ ajvInstance.compile(schema);
41
+ return { isValid: true };
42
+ }
43
+ catch (error) {
44
+ const errorMessage = error instanceof Error ? error.message : String(error);
45
+ return { isValid: false, error: errorMessage };
46
+ }
47
+ }
48
+ function createValidator(schema, ajvInstance = defaultAjv) {
49
+ return ajvInstance.compile(schema);
50
+ }
51
+ function transformValidationErrors(validator) {
52
+ return (validator.errors?.map((err) => ({
53
+ field: err.instancePath || '/',
54
+ message: err.message || 'Validation failed',
55
+ keyword: err.keyword,
56
+ params: err.params || {},
57
+ })) || []);
58
+ }
59
+ function validateData(validator, data) {
60
+ const isValid = validator(data);
61
+ const errors = isValid ? [] : transformValidationErrors(validator);
62
+ return { isValid: Boolean(isValid), errors };
63
+ }
64
+ function formatValidationErrorMessage(errors) {
65
+ return errors.map((err) => `${err.field}: ${err.message}`).join(', ');
66
+ }
67
+ function getSupportedFormats() {
68
+ return [
69
+ 'date',
70
+ 'time',
71
+ 'date-time',
72
+ 'duration',
73
+ 'uri',
74
+ 'uri-reference',
75
+ 'uri-template',
76
+ 'url',
77
+ 'email',
78
+ 'hostname',
79
+ 'ipv4',
80
+ 'ipv6',
81
+ 'regex',
82
+ 'uuid',
83
+ 'json-pointer',
84
+ 'relative-json-pointer',
85
+ 'byte',
86
+ 'int32',
87
+ 'int64',
88
+ 'float',
89
+ 'double',
90
+ 'password',
91
+ 'binary',
92
+ ];
93
+ }
94
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,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,MAAM;QACN,cAAc;QACd,uBAAuB;QACvB,MAAM;QACN,OAAO;QACP,OAAO;QACP,OAAO;QACP,QAAQ;QACR,UAAU;QACV,QAAQ;KACR,CAAC;AACH,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface ValidationError {
2
+ field: string;
3
+ message: string;
4
+ keyword: string;
5
+ params: Record<string, unknown>;
6
+ }
7
+ export interface ValidationResult {
8
+ isValid: boolean;
9
+ errors: ValidationError[];
10
+ }
11
+ export type DataSource = 'entireItem' | 'customJson';
12
+ export interface SchemaDefinition {
13
+ name: string;
14
+ schema: object;
15
+ dataSource: DataSource;
16
+ customJsonPath?: string;
17
+ }
18
+ export interface MultiSchemaValidationResult {
19
+ schemaName: string;
20
+ isValid: boolean;
21
+ errors: ValidationError[];
22
+ }
23
+ export interface ValidatorOptions {
24
+ allErrors: boolean;
25
+ strict: boolean;
26
+ verbose: boolean;
27
+ useFormats: boolean;
28
+ useCustomErrors: boolean;
29
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../nodes/SchemaValidator/types.ts"],"names":[],"mappings":""}
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "@cdmx/n8n-nodes-schema-validator",
3
+ "version": "0.1.1",
4
+ "description": "AJV JSON Schema validation node for n8n workflows with support for multiple schemas, formats, and enhanced error messages",
5
+ "keywords": [
6
+ "n8n-community-node-package",
7
+ "n8n",
8
+ "json-schema",
9
+ "validation",
10
+ "ajv",
11
+ "ajv-formats",
12
+ "ajv-errors"
13
+ ],
14
+ "license": "MIT",
15
+ "homepage": "https://github.com/yourusername/n8n-nodes-schema-validator",
16
+ "author": {
17
+ "name": "Your Name",
18
+ "email": "your@email.com"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/yourusername/n8n-nodes-schema-validator.git"
23
+ },
24
+ "engines": {
25
+ "node": ">=18.10",
26
+ "pnpm": ">=9.1"
27
+ },
28
+ "packageManager": "pnpm@9.1.4",
29
+ "main": "dist/nodes/SchemaValidator/SchemaValidator.node.js",
30
+ "scripts": {
31
+ "build": "tsc && gulp build:icons",
32
+ "dev": "tsc --watch",
33
+ "format": "prettier --write \"**/*.{ts,json}\"",
34
+ "format:check": "prettier --check \"**/*.{ts,json}\"",
35
+ "lint": "eslint nodes --ext .ts",
36
+ "lint:fix": "eslint nodes --ext .ts --fix",
37
+ "test": "jest",
38
+ "test:watch": "jest --watch",
39
+ "test:coverage": "jest --coverage",
40
+ "prepublishOnly": "npm run build",
41
+ "publish-dry-run": "npm publish --access public --dry-run",
42
+ "publish-pkg": "npm publish --access public"
43
+ },
44
+ "files": [
45
+ "dist"
46
+ ],
47
+ "n8n": {
48
+ "n8nNodesApiVersion": 1,
49
+ "credentials": [],
50
+ "nodes": [
51
+ "dist/nodes/SchemaValidator/SchemaValidator.node.js"
52
+ ]
53
+ },
54
+ "devDependencies": {
55
+ "@types/jest": "^29.5.12",
56
+ "@types/node": "^20.14.0",
57
+ "@typescript-eslint/eslint-plugin": "^7.11.0",
58
+ "@typescript-eslint/parser": "^7.11.0",
59
+ "eslint": "^8.57.0",
60
+ "gulp": "^5.0.0",
61
+ "jest": "^29.7.0",
62
+ "n8n-workflow": "^1.48.0",
63
+ "prettier": "^3.2.5",
64
+ "ts-jest": "^29.1.4",
65
+ "typescript": "^5.4.5"
66
+ },
67
+ "dependencies": {
68
+ "ajv": "^8.16.0",
69
+ "ajv-errors": "^3.0.0",
70
+ "ajv-formats": "^3.0.1"
71
+ },
72
+ "peerDependencies": {
73
+ "n8n-workflow": "^1.0.0"
74
+ },
75
+ "overrides": {
76
+ "form-data": "^4.0.5"
77
+ }
78
+ }
79
+