A simple Node.js tool that validates JSON data against predefined parameters. Perfect for checking if your data contains all the required fields for ecommerce events.
This tool helps you verify that your JSON data contains all the parameters defined in your conditions file. It's like a checklist that automatically checks if your data has all the required fields.
Before you start, make sure you have these installed on your computer:
- What it is: A JavaScript runtime that lets you run JavaScript outside of a web browser
- How to install:
- Go to nodejs.org
- Download the "LTS" version (recommended for most users)
- Run the installer and follow the instructions
- How to check if it's installed: Open your terminal/command prompt and type
node --version
git clone https://github.com/eliottp-git/mtb_event_testing.git
cd mtb_event_testing
npm install
What this does: Downloads all the required packages (like lodash) that the project needs to work.
npm start
What this does: Runs the validation tool and shows you which parameters are found or missing in your data.
- What it is: Your test data (the JSON object you want to check)
- What to do: Replace this with your the JSON object returned from the dataLayer
- An example is provided
- What it is: Defines all the parameters that should exist in your data
- What to do: Add or remove parameters as needed (each line starting with
$
is a parameter). Copy paste the content of the parameter requirements in between the `` quotes - An example is provided
- What it is: The main logic that does the validation
- What to do: You usually don't need to modify this unless you want to add new features
When you run the tool, you'll see something like this: