Validations

A migration enforces the database. A validation enforces Ruby.

null: false on the dogs.name column stops a nameless row from ever reaching the database β€” but it does that with a low-level SQL error, which is a harsh way to find out. Validations live in the model instead, run in Ruby before any SQL fires, and give you back a friendly, structured list of what's wrong:

class Dog < ApplicationRecord
  validates :name, presence: true
  validates :size, inclusion: { in: %w[small medium large] }
end

This is the SAME validation the real PawWalk backend's Dog model has β€” open apps/pawwalk-api/app/models/dog.rb in a later module and you'll recognize both lines exactly.