Validate Google Cloud Spanner data (emulator supported) against expectations written in YAML. Simple CLI, fast feedback.
go install github.com/nu0ma/spalidate@latest
-
Start the Spanner emulator and set
SPANNER_EMULATOR_HOST
. -
Create expected YAML (example):
# validation.yaml
tables:
Users:
columns:
- UserID: "user-001"
Name: "Alice Johnson"
Email: "[email protected]"
Status: 1
CreatedAt: "2024-01-01T00:00:00Z"
Products:
columns:
- ProductID: "prod-001"
Name: "Laptop Computer"
Price: 150000
IsActive: true
CategoryID: "cat-electronics"
CreatedAt: "2024-01-01T00:00:00Z"
Books:
columns:
- BookID: "book-001"
Title: "The Great Gatsby"
Author: "F. Scott Fitzgerald"
PublishedYear: 1925
JSONData: '{"genre": "Fiction", "rating": 4.5}'
- Run
spalidate --project <your-project> --instance <your-instance> --database <your-database> ./validation.yaml
On success: Validation passed for all tables
2025/09/13 19:09:25 ERRO ✖️ table Books: expected row does not match
column mismatch: 1
1) column: JSONData
▸ expected: {"genre":"Fiction","ratifeawfng":4.5}
▸ actual: {"genre": "invalid", "rating": 4.5}
2025/09/13 19:09:25 ERRO ✖️ table Products: expected row does not match
column mismatch: 1
1) column: CategoryID
▸ expected: cat-electronieeecs
▸ actual: cat-electronics
2025/09/13 19:09:25 ERRO ✖️ table Users: expected row does not match
column mismatch: 2
1) column: Email
▸ expected: [email protected]
▸ actual: [email protected]
2) column: Status
▸ expected: 999
▸ actual: 1
You will see logs like the ones shown above.
MIT