{
  "name": "Sample - Privacy-safe Input Quality Gate",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "sample-input-quality-gate",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook",
      "name": "Receive Sample Input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [-420, 0]
    },
    {
      "parameters": {
        "jsCode": "const body = $json.body ?? $json;\nconst clean = value => String(value ?? '').trim().replace(/\\s+/g, ' ');\nconst contact = clean(body.contact);\nconst workflow = clean(body.workflow);\nconst errors = [];\nif (contact.length < 3) errors.push('contact is required');\nif (workflow.length < 12) errors.push('workflow must be at least 12 characters');\nreturn [{ json: { ok: errors.length === 0, errors, data: { contact, workflow, source: clean(body.source) || 'unknown' }, checkedAt: new Date().toISOString() } }];"
      },
      "id": "validate",
      "name": "Normalize and Validate",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [-180, 0]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 },
          "conditions": [{ "id": "is-valid", "leftValue": "={{ $json.ok }}", "rightValue": true, "operator": { "type": "boolean", "operation": "true", "singleValue": true } }],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "if-valid",
      "name": "Input Is Valid?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [60, 0]
    },
    {
      "parameters": { "respondWith": "json", "responseBody": "={{ $json }}", "options": { "responseCode": 200 } },
      "id": "success",
      "name": "Return Success",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [320, -100]
    },
    {
      "parameters": { "respondWith": "json", "responseBody": "={{ $json }}", "options": { "responseCode": 422 } },
      "id": "failure",
      "name": "Return Validation Error",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [320, 100]
    }
  ],
  "connections": {
    "Receive Sample Input": { "main": [[{ "node": "Normalize and Validate", "type": "main", "index": 0 }]] },
    "Normalize and Validate": { "main": [[{ "node": "Input Is Valid?", "type": "main", "index": 0 }]] },
    "Input Is Valid?": { "main": [[{ "node": "Return Success", "type": "main", "index": 0 }], [{ "node": "Return Validation Error", "type": "main", "index": 0 }]] }
  },
  "pinData": {},
  "active": false,
  "settings": { "executionOrder": "v1" },
  "versionId": "00000000-0000-4000-8000-000000000072",
  "meta": { "templateCredsSetupCompleted": true },
  "tags": []
}
