
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
DbValidator helps identify invalid records in your Rails application that don't meet model validation requirements. It finds records that became invalid after validation rule changes, and validates imported or manually edited data. You can use it to audit records before deploying new validations and catch any data that bypassed validation checks.
Add this line to your application's Gemfile:
gem 'db_validator'
Then execute:
$ bundle install
The simplest way to run validation is using the provided rake task:
$ rake db_validator:validate
This will start an interactive mode where you can select which models to validate and adjust other options.
$ rake db_validator:validate models=user,post
$ rake db_validator:validate limit=1000
$ rake db_validator:validate format=json
You can test new validation rules before applying them to your models:
$ rake db_validator:test model=User rule='validates :name, presence: true'
Here's an example of testing email format validation rules:
# Testing invalid email format (without @)
$ rake db_validator:test model=User rule='validates :email, format: { without: /@/, message: "must contain @" }'
Found 100 records that would become invalid out of 100 total records.
# Testing valid email format (with @)
$ rake db_validator:test model=User rule='validates :email, format: { with: /@/, message: "must contain @" }'
No invalid records found.
Trying to test a validation rule for a non-existent attribute will return an error:
❌ Error: Attribute 'i_dont_exist' does not exist for model 'User'
Available columns: id, email, created_at, updated_at, name
You can also run validation from your Ruby code:
report = DbValidator.validate
report = DbValidator.validate(
only_models: ['User', 'Post'],
limit: 1000,
report_format: :json
)
DbValidator Report
==================
Found invalid records:
User: 2 invalid records
ID: 1
email is invalid (actual value: "invalid-email")
ID: 2
name can't be blank (actual value: "")
Post: 1 invalid record
ID: 5
title can't be blank (actual value: "")
category is not included in the list (allowed values: news, blog, actual value: "invalid")
The JSON report is saved to a file in the db_validator_reports
directory.
{
"User": {
"error_count": 2,
"records": [
{
"id": 1,
"errors": [
"email is invalid (actual value: \"invalid-email\")"
]
},
{
"id": 2,
"errors": [
"name can't be blank (actual value: \"\")"
]
}
]
}
}
FAQs
Unknown package
We found that db_validator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.