Back to rules

SSCC (Serial Shipping Container Code) Validation

formathigh

Validates Serial Shipping Container Code (SSCC) format per GS1 General Specifications. SSCC is an 18-digit identifier used to uniquely identify logistics units (pallets, cases, parcels) throughout the supply chain. Structure: 1-digit extension digit (0-9), 7-digit GS1 company prefix, 9-digit serial reference, and 1-digit mod-10 check digit. The check digit uses the standard GS1 algorithm: multiply digits alternately by 3 and 1 (from position 1), sum, check = (10 - sum % 10) % 10.

v1.0.0by dqhub789 downloads3.8 (46)
shippinggs1supply-chainsscccontainerlogisticsbarcode
Try This Rule

Parameters

column_namestringrequired

The column containing email addresses

thresholdfloatdefault: 0.99

Minimum fraction of valid emails (0.0 to 1.0)

Install

soda
checks for {{table_name}}:
  - invalid_percent({{column_name}}) < {{(1 - threshold) * 100}}:
      valid regex: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
dbt
{% test valid_email(model, column_name) %}
select {{ column_name }}
from {{ model }}
where {{ column_name }} not regexp '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'
{% endtest %}
sql
SELECT COUNT(*) as total,
  SUM(CASE WHEN {{column_name}} REGEXP
    '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$'
    THEN 1 ELSE 0 END) as valid
FROM {{table_name}}
Great Expectations
{
  "expectation_type": "expect_column_values_to_match_regex",
  "kwargs": {
    "column": "{{column_name}}",
    "regex": "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",
    "mostly": {{threshold}}
  }
}
spark
from pyspark.sql.functions import col
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
invalid = df.filter(~col("{{column_name}}").rlike(pattern)).count()

Test Data

Passing Examples

idvalue
1alice@example.com
2bob.smith@company.co.uk
3charlie+tag@domain.org

Failing Examples

idvalue
1not-an-email
2@missing-local.com
3spaces in@email.com

CLI

Terminal
npx dqhub install sscc-format --format soda --table YOUR_TABLE
npx dqhub install sscc-format --format dbt --model YOUR_MODEL
npx dqhub install sscc-format --format sql --dialect snowflake