Skip to main content
Version: Next

validate command

The validate command allows you to perform a validation procedure and compare transformed data.

Below is a list of all supported flags for the validate command:

Supported flags
Usage:
greenmask validate [flags]

Flags:
--data Perform test dump for --rows-limit rows and print it pretty
--diff Find difference between original and transformed data
--diff-mode string How to show the diff (only with --data and --diff). Possible values [values|summary]. summary prints per-column counts of changed rows and no original or transformed value (default "values")
--diff-unchanged-threshold float With --diff-mode=summary, warn when a transformed column keeps more than this percentage of its non-NULL values (0-100, 100 turns the warning off). Counts cover --rows-limit rows only (default 90)
--format string Format of output. possible values [text|json] (default "text")
--rows-limit uint Check tables dump only for specific tables (default 10)
--schema Make a schema diff between previous dump and the current state
--strict Exit with non-zero code if there are any validation warnings (warnings-as-errors)
--table strings Check tables dump only for specific tables
--table-format string Format of table output (only for --format=text). Possible values [vertical|horizontal] (default "vertical")
--transformed-only Print only transformed column and primary key
--warnings Print warnings

Validate command can exit with non-zero code when:

  • Any error occurred
  • There is a validation warning with severity "error"
  • Validate was called with --strict flag and there are any unresolved warnings (warnings-as-errors)
  • Validate was called with --schema flag and there are schema differences
  • Validate was called with --strict and --diff-mode=summary and the summary has an unresolved column warning

The --warnings flag only controls printing of warnings — it does not affect the exit code. In strict mode warnings are always printed regardless of --warnings, and warnings whose hash is listed in resolved_warnings are not treated as failures.

These non-zero exit codes let CI/CD pipelines stop on problems — particularly useful with --schema or --strict, which guard against data leakage on schema changes and enforce a clean validation result.

You can use the --table flag multiple times to specify the tables you want to check. Tables can be written with or without schema names (e.g., public.table_name or table_name). If you specify multiple tables from different schemas, an error will be thrown.

To start validation, use the following command:

greenmask --config=config.yml validate \
--warnings \
--data \
--diff \
--schema \
--format=text \
--table-format=vertical \
--transformed-only \
--rows-limit=1
Validation output example
2024-03-15T19:46:12+02:00 WRN ValidationWarning={"hash":"aa808fb574a1359c6606e464833feceb","meta":{"ColumnName":"birthdate","ConstraintDef":"CHECK (birthdate \u003e= '1930-01-01'::date AND birthdate \u003c= (now() - '18 years'::interval))","ConstraintName":"humanresources","ConstraintSchema":"humanresources","ConstraintType":"Check","ParameterName":"column","SchemaName":"humanresources","TableName":"employee","TransformerName":"NoiseDate"},"msg":"possible constraint violation: column has Check constraint","severity":"warning"}

The validation output will provide detailed information about potential constraint violations and schema issues. Each line contains nested JSON data under the ValidationWarning key, offering insights into the affected part of the configuration and potential constraint violations.

Pretty formatted validation warning
{
"hash": "aa808fb574a1359c6606e464833feceb", // (13)
"meta": { // (1)
"ColumnName": "birthdate", // (2)
"ConstraintDef": "CHECK (birthdate >= '1930-01-01'::date AND birthdate <= (now() - '18 years'::interval))", // (3)
"ConstraintName": "humanresources", // (4)
"ConstraintSchema": "humanresources", // (5)
"ConstraintType": "Check", // (6)
"ParameterName": "column", // (7)
"SchemaName": "humanresources", // (8)
"TableName": "employee", // (9)
"TransformerName": "NoiseDate" // (10)
},
"msg": "possible constraint violation: column has Check constraint", // (11)
"severity": "warning" // (12)
}
  1. Detailed metadata. The validation output provides comprehensive metadata to pinpoint the source of problems.
  2. Column name indicates the name of the affected column.
  3. Constraint definition specifies the definition of the constraint that may be violated.
  4. Constraint name identifies the name of the constraint that is potentially violated.
  5. Constraint schema name indicates the schema in which the constraint is defined.
  6. Type of constraint represents the type of constraint and can be one of the following:
    * ForeignKey
    * Check
    * NotNull
    * PrimaryKey
    * PrimaryKeyReferences
    * Unique
    * Length
    * Exclusion
    * TriggerConstraint
  7. Table schema name specifies the schema name of the affected table.
  8. Table name identifies the name of the table where the problem occurs.
  9. Transformer name indicates the name of the transformer responsible for the transformation.
  10. Name of affected parameter typically, this is the name of the column parameter that is relevant to the validation warning.
  11. Validation warning description provides a detailed description of the validation warning and the reason behind it.
  12. Severity of validation warning indicates the severity level of the validation warning and can be one of the following:
    * error
    * warning
    * info
    * debug
  13. Hash is a unique identifier of the validation warning. It is used to resolve the warning in the config file
note

A validation warning with a severity level of "error" is considered critical and must be addressed before the dump operation can proceed. Failure to resolve such warnings will prevent the dump operation from being executed. See Validation errors and warnings.

Schema diff changed output example
2024-03-15T19:46:12+02:00 WRN Database schema has been changed Hint="Check schema changes before making new dump" PreviousDumpId=1710520855501
2024-03-15T19:46:12+02:00 WRN Column renamed Event=ColumnRenamed Signature={"CurrentColumnName":"id1","PreviousColumnName":"id","TableName":"test","TableSchema":"public"}
2024-03-15T19:46:12+02:00 WRN Column type changed Event=ColumnTypeChanged Signature={"ColumnName":"id","CurrentColumnType":"bigint","CurrentColumnTypeOid":"20","PreviousColumnType":"integer","PreviousColumnTypeOid":"23","TableName":"test","TableSchema":"public"}
2024-03-15T19:46:12+02:00 WRN Column created Event=ColumnCreated Signature={"ColumnName":"name","ColumnType":"text","TableName":"test","TableSchema":"public"}
2024-03-15T19:46:12+02:00 WRN Table created Event=TableCreated Signature={"SchemaName":"public","TableName":"test1","TableOid":"20563"}

Example of validation diff:

img.png

The validation diff is presented in a neatly formatted table. In this table:

  • Columns that are affected by the transformation are highlighted with a red background.
  • The pre-transformation values are displayed in green.
  • The post-transformation values are shown in red.
  • Colors are printed only when stdout is a terminal. Set NO_COLOR=1 to turn them off, or FORCE_COLOR=1 to keep them when the output goes to a pipe or a file, for example | less -R.
  • The result in --format=text can be displayed in either horizontal (--table-format=horizontal) or vertical (--table-format=vertical) format, making it easy to visualize and understand the differences between the original and transformed data.

The whole validate command may be run in json format including logging making easy to parse the structure.

greenmask --config=config.yml validate \
--warnings \
--data \
--diff \
--schema \
--format=json \
--table-format=vertical \
--transformed-only \
--rows-limit=1 \
--log-format=json

The json object result

{
"level": "warn",
"ValidationWarning": {
"msg": "possible constraint violation: column has Check constraint",
"severity": "warning",
"meta": {
"ColumnName": "birthdate",
"ConstraintDef": "CHECK (birthdate >= '1930-01-01'::date AND birthdate <= (now() - '18 years'::interval))",
"ConstraintName": "humanresources",
"ConstraintSchema": "humanresources",
"ConstraintType": "Check",
"ParameterName": "column",
"SchemaName": "humanresources",
"TableName": "employee",
"TransformerName": "NoiseDate"
},
"hash": "aa808fb574a1359c6606e464833feceb"
},
"time": "2024-03-15T20:01:51+02:00"
}

Validation errors and warnings​

validate and dump check the configuration in the same way, against the live database schema, before any data is read. Each problem is a validation warning with one of these severities:

  • error — the configuration cannot be applied. It is fatal: dump aborts and validate exits with a non-zero code.
  • warning, info, debug — a hint, for example a possible constraint violation. It never stops dump. With --strict, an unresolved warning makes validate exit with a non-zero code.

Greenmask does not skip a transformer it cannot apply. A table, transformer, parameter or column in the transformation config that does not exist is an error:

ProblemmsgMain meta keys
Table does not existtable is not foundSchema, TableName
Unknown transformer nametransformer not foundTransformerName
Unknown parameter namereceived unknown parameterParameterName
Column parameter (such as column) names a missing columncolumn does not existColumnName, ParameterName
Dynamic parameter column names a missing columncolumn does not existDynamicParameterSetting: column, ParameterName
Cmd transformer columns item names a missing columncolumn not foundColumnName, ElementNum

For example, a RandomEmail transformer on a column email that the public.users table does not have:

Missing column error
2026-10-25T10:12:03+02:00 ERR ValidationWarning={"hash":"","meta":{"ColumnName":"email","ParameterName":"column","SchemaName":"public","TableName":"users","TransformerName":"RandomEmail"},"msg":"column does not exist","severity":"error"}

validate prints the same line with the warning hash filled in. If a table in the config is missing, only the missing tables are reported: the transformers are checked on the next run, after the tables are fixed. Otherwise error warnings from all tables and transformers are reported in one run.

How the two commands handle the result:

dumpvalidate
error warningsLogged, then the dump stops with context error: fatal validation error before the schema is dumped. Nothing is written to storage.Logged, then exits with code 1 and fatal validation error.
warning, info, debug warningsNot printed, the dump goes on.Printed with --warnings or --strict. Exit code 1 only with --strict and only for unresolved warning.
validate.resolved_warningsNot used.Hides the listed warnings. An error hash in the list fails validate with warning with hash ... cannot be excluded because it is an error.
Tables checkedEvery table in dump.transformation.The --table tables if set, otherwise every table in dump.transformation.

So run validate without --table to see every error that would stop dump.

warning

A column in a when condition is not checked during validation. If record.<column> or raw_record.<column> names a column that does not exist, the condition fails on the first row of the table with error evaluating when condition: unable to evaluate when condition: invalid operation: cannot call nil, and dump stops in the data stage. validate finds it only with --data and only if the table has rows.

Summary diff​

--diff prints original values next to transformed ones. That is fine against a staging copy, but not where production data may be read and must not be shown: a CI job whose logs are kept, a shared terminal, or an AI agent's transcript. --diff-mode=summary compares the same rows and prints counts only, per table and column. It prints no original or transformed value and no primary key.

greenmask --config=config.yml validate \
--data \
--diff \
--diff-mode=summary \
--rows-limit=1000
Summary diff output example
"humanresources"."employee" (290 rows compared, values not shown)
+------------------+-------------+---------+-----------+------------+-------------+--------------------------------------------------+
| Column | Transformed | Changed | Unchanged | NULLs kept | Unchanged % | Warning |
+------------------+-------------+---------+-----------+------------+-------------+--------------------------------------------------+
| businessentityid | no | 0 | 290 | 0 | 100.0 | |
| birthdate | yes | 290 | 0 | 0 | 0.0 | |
| loginid | yes | 12 | 278 | 0 | 95.9 | transformed column is unchanged in too many rows |
+------------------+-------------+---------+-----------+------------+-------------+--------------------------------------------------+

For each column:

  • Transformed — whether a transformer in the config affects the column.
  • Changed, Unchanged — rows where the value did or did not change.
  • NULLs kept — rows where the value was NULL before and after. These are left out of the unchanged ratio, because keeping NULL is the usual behaviour of most transformers.
  • Warning:
    • transformed column is unchanged in too many rows — a transformed column kept more than --diff-unchanged-threshold percent (default 90) of its non-NULL values. This usually means a missed or no-op transformer, for example a Replace with a value most rows already have. Set the threshold to 100 to turn the warning off. The warning is a hint, not a proof: a transformer with few possible outputs keeps many values by design. RandomBool keeps about half of them, RandomChoice with two values the same, and a small-range NoiseInt or NoiseDate can keep more. Small --rows-limit samples make the ratio noisy too.
    • column changed but no transformer affects it — the column changed, but no transformer in the config targets it.

Each column warning is also a validation warning with a hash, printed with --warnings or --strict like any other warning. Its meta.WarningType is UnchangedRowsPercentageThresholdExceeded or UntransformedColumnChanged. With --format=json the hash is also in the column's hash field; with --format=text it is only in that log output. The hash covers the message, severity, warning type, schema, table and column but not the row counts, so it stays the same when the counts change. Add it to validate.resolved_warnings to accept the warning, for example for a RandomBool column:

Resolving a summary warning
validate:
resolved_warnings:
- "e2550a86b34552c742bc1dafffa632de"

With --format=json each table is one JSON object:

Summary diff in json format
{
"schema": "humanresources",
"name": "employee",
"diff_mode": "summary",
"rows": 290,
"columns": [
{
"name": "loginid",
"transformed": true,
"changed": 12,
"unchanged": 278,
"nulls_kept": 0,
"unchanged_ratio": 0.9586206896551724,
"warning": "transformed column is unchanged in too many rows",
"hash": "e2550a86b34552c742bc1dafffa632de"
}
]
}

Things to know:

  • The summary needs --diff: --data with --diff-mode=summary and without --diff is an error, because plain --data prints every value. Without --data diff_mode is ignored, so diff_mode: summary can stay in the config.
  • The counts cover the --rows-limit rows that validate dumps (default 10). Use a larger --rows-limit for a ratio you can trust.
  • With --transformed-only, the summary lists transformed columns and any column with an unresolved warning. --table-format does not apply: the summary has one layout.
  • A transformer with a when condition counts as affecting the column in every row, so rows the condition skips count as unchanged.
  • With --strict, any column warning not listed in resolved_warnings makes validate exit with a non-zero code.
  • Resolved warnings are not shown in the summary table or json, like any other resolved warning. The column itself and its counts stay.
  • --diff-unchanged-threshold is checked only with --diff-mode=summary.
Tools and expertise for reproducible, production-like environments.
Copyright © 2026 Greenmask, Inc.
Privacy Policy