Supplier catalogs

How to skip JSON products with invalid barcode

2026-06-29
Task

Some products in a JSON catalog have an empty or too-short barcode. The import should keep only items with a valid-looking code.

Short answer

Open barcode and add an export condition: regular expression ^(?:[0-9]{8}|[0-9]{12,14})$ (matches a digits-only string with length 8, 12, 13, or 14; it does not validate the check digit).

How to do it in Eofferix

  1. In the JSON snapshot, select barcode inside the repeated block.

    JSON field barcode
    The selected field belongs to one repeated object.
  2. Open the value settings.

    Opening barcode settings
    The animation shows opening the field settings.
  3. Add an export condition: barcode ^(?:[0-9]{8}|[0-9]{12,14})$.

    JSON condition
    The condition selects only the needed object before export.

Before / after

Before

source data
{
    "products": [
        {
            "sku": "SKU-15001",
            "name": "Hudson lamp",
            "barcode": "4601234567890",
            "price": "1290.00"
        },
        {
            "sku": "SKU-15002",
            "name": "Parker chair",
            "barcode": "12345",
            "price": "8400.00"
        },
        {
            "sku": "SKU-15003",
            "name": "Harbor shelf",
            "barcode": "",
            "price": "990.00"
        }
    ]
}

After

result
{
    "products": [
        {
            "sku": "SKU-15001",
            "name": "Hudson lamp",
            "barcode": "4601234567890",
            "price": "1290.00"
        }
    ]
}

What to keep in mind

  • The regular expression checks the format, but not the mathematical EAN/GTIN check digit.
  • If your catalog allows internal barcodes with another length, change the list of lengths in the expression.

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up