{
  "$meta": {
    "package": "@walkeros/transformer-validator",
    "version": "4.0.2",
    "type": "transformer",
    "platform": [
      "web",
      "server"
    ],
    "docs": "https://www.walkeros.io/docs/transformers/validator",
    "source": "https://github.com/elbwalker/walkerOS/tree/main/packages/transformers/validator/src"
  },
  "schemas": {
    "format": {
      "type": "object",
      "required": [
        "name",
        "entity",
        "action",
        "data",
        "globals",
        "custom",
        "user",
        "consent",
        "id",
        "trigger",
        "timestamp",
        "timing",
        "source"
      ],
      "properties": {
        "name": {
          "type": "string",
          "pattern": "^\\S+ \\S+$"
        },
        "entity": {
          "type": "string"
        },
        "action": {
          "type": "string"
        },
        "data": {
          "type": "object"
        },
        "context": {
          "type": "object"
        },
        "globals": {
          "type": "object"
        },
        "custom": {
          "type": "object"
        },
        "user": {
          "type": "object"
        },
        "nested": {
          "type": "array"
        },
        "consent": {
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "trigger": {
          "type": "string"
        },
        "timestamp": {
          "type": "number"
        },
        "timing": {
          "type": "number"
        },
        "source": {
          "type": "object",
          "required": [
            "type"
          ],
          "properties": {
            "type": {
              "type": "string"
            },
            "platform": {
              "type": "string"
            },
            "url": {
              "type": "string"
            },
            "referrer": {
              "type": "string"
            },
            "schema": {
              "type": "string"
            },
            "version": {
              "type": "string"
            },
            "count": {
              "type": "number"
            },
            "trace": {
              "type": "string"
            },
            "tool": {
              "type": "string"
            },
            "command": {
              "type": "string"
            }
          }
        }
      }
    },
    "settings": {
      "type": "object",
      "properties": {
        "format": {
          "type": "boolean",
          "description": "Validate full WalkerOS.Event structure. Pre-compiled at init.",
          "default": true
        },
        "contract": {
          "type": "object",
          "description": "Event-specific validation rules. Entity/action keyed, supports wildcards."
        }
      }
    }
  },
  "examples": {
    "step": {
      "contractValidationPass": {
        "title": "Contract validation",
        "description": "Contract validation passes when event data matches the entity.action JSON Schema",
        "in": {
          "name": "order complete",
          "data": {
            "id": "0rd3r1d",
            "total": 555,
            "currency": "EUR"
          },
          "context": {
            "shopping": [
              "complete",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [
            {
              "entity": "product",
              "data": {
                "id": "ers",
                "name": "Everyday Ruck Snack",
                "color": "black",
                "size": "l",
                "price": 420
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "product",
              "data": {
                "id": "cc",
                "name": "Cool Cap",
                "size": "one size",
                "price": 42
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            },
            {
              "entity": "gift",
              "data": {
                "name": "Surprise"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "nested": []
            }
          ],
          "consent": {
            "functional": true
          },
          "id": "ev-1700000800",
          "trigger": "load",
          "entity": "order",
          "action": "complete",
          "timestamp": 1700000800,
          "timing": 3.14,
          "source": {
            "type": "browser",
            "platform": "web",
            "url": "https://shop.example.com/"
          }
        },
        "out": [
          [
            "return",
            {
              "name": "order complete",
              "data": {
                "id": "0rd3r1d",
                "total": 555,
                "currency": "EUR"
              },
              "context": {
                "shopping": [
                  "complete",
                  0
                ]
              },
              "globals": {
                "pagegroup": "shop"
              },
              "custom": {
                "completely": "random"
              },
              "user": {
                "id": "us3r",
                "device": "c00k13",
                "session": "s3ss10n"
              },
              "nested": [
                {
                  "entity": "product",
                  "data": {
                    "id": "ers",
                    "name": "Everyday Ruck Snack",
                    "color": "black",
                    "size": "l",
                    "price": 420
                  },
                  "context": {
                    "shopping": [
                      "complete",
                      0
                    ]
                  },
                  "nested": []
                },
                {
                  "entity": "product",
                  "data": {
                    "id": "cc",
                    "name": "Cool Cap",
                    "size": "one size",
                    "price": 42
                  },
                  "context": {
                    "shopping": [
                      "complete",
                      0
                    ]
                  },
                  "nested": []
                },
                {
                  "entity": "gift",
                  "data": {
                    "name": "Surprise"
                  },
                  "context": {
                    "shopping": [
                      "complete",
                      0
                    ]
                  },
                  "nested": []
                }
              ],
              "consent": {
                "functional": true
              },
              "id": "ev-1700000800",
              "trigger": "load",
              "entity": "order",
              "action": "complete",
              "timestamp": 1700000800,
              "timing": 3.14,
              "source": {
                "type": "browser",
                "platform": "web",
                "url": "https://shop.example.com/"
              }
            }
          ]
        ]
      },
      "invalidFormat": {
        "public": false,
        "in": {
          "name": "invalid",
          "data": {}
        },
        "out": [
          [
            "return",
            false
          ]
        ]
      },
      "validEvent": {
        "title": "Valid event",
        "description": "A well-formed product view passes validation and is returned unchanged for downstream destinations.",
        "in": {
          "name": "product view",
          "data": {
            "id": "SKU-100",
            "name": "Trail Runner Pro",
            "price": 129.99
          },
          "context": {
            "shopping": [
              "detail",
              0
            ]
          },
          "globals": {
            "pagegroup": "shop"
          },
          "custom": {
            "completely": "random"
          },
          "user": {
            "id": "us3r",
            "device": "c00k13",
            "session": "s3ss10n"
          },
          "nested": [],
          "consent": {
            "functional": true
          },
          "id": "ev-1700000700",
          "trigger": "load",
          "entity": "product",
          "action": "view",
          "timestamp": 1700000700,
          "timing": 3.14,
          "source": {
            "type": "browser",
            "platform": "web",
            "url": "https://example.com/"
          }
        },
        "out": [
          [
            "return",
            {
              "name": "product view",
              "data": {
                "id": "SKU-100",
                "name": "Trail Runner Pro",
                "price": 129.99
              },
              "context": {
                "shopping": [
                  "detail",
                  0
                ]
              },
              "globals": {
                "pagegroup": "shop"
              },
              "custom": {
                "completely": "random"
              },
              "user": {
                "id": "us3r",
                "device": "c00k13",
                "session": "s3ss10n"
              },
              "nested": [],
              "consent": {
                "functional": true
              },
              "id": "ev-1700000700",
              "trigger": "load",
              "entity": "product",
              "action": "view",
              "timestamp": 1700000700,
              "timing": 3.14,
              "source": {
                "type": "browser",
                "platform": "web",
                "url": "https://example.com/"
              }
            }
          ]
        ]
      }
    }
  }
}