# Let the database reject bad data

> Duplicates, empty fields and orphaned rows creep in because only the form checks them.

Web page: https://buildladder.com/resources/prompts/database-rules

What you get: Constraints for the rules that matter, and a clean-up plan for rows that already break them.

Paste it into: Your AI tool, in your project

## Prompt to copy

```text
My app only validates data in the form, so bad rows still get into the database.

Read the schema and the code and list the rules the data is supposed to follow: required fields, unique values such as email, allowed status values, amounts that can't be negative, rows that must belong to an existing parent. Mark which ones the database enforces today.

For each missing rule, first count the existing rows that break it and show me examples. Propose how to clean those up, then add the constraint in a migration. Make sure the app shows a friendly message when the database says no, instead of a raw error.
```
