diff --git a/app/models/creature.rb b/app/models/creature.rb index 70eecdf..3563796 100644 --- a/app/models/creature.rb +++ b/app/models/creature.rb @@ -3,6 +3,9 @@ class Creature < ApplicationRecord enum :size, [:small, :big, :giant] + validates :name, presence: true + validates :health_points, numericality: { greater_than_or_equal_to: 0 } + def alive? self.health_points > 0 end