diff --git a/lib/pento/catalog/product.ex b/lib/pento/catalog/product.ex index e337515..b124d6b 100644 --- a/lib/pento/catalog/product.ex +++ b/lib/pento/catalog/product.ex @@ -17,5 +17,6 @@ defmodule Pento.Catalog.Product do |> cast(attrs, [:name, :description, :unit_price, :sku]) |> validate_required([:name, :description, :unit_price, :sku]) |> unique_constraint(:sku) + |> validate_number(:unit_price, greater_than: 0.0) end end diff --git a/lib/pento_web/router.ex b/lib/pento_web/router.ex index 20f928d..c07dd22 100644 --- a/lib/pento_web/router.ex +++ b/lib/pento_web/router.ex @@ -26,6 +26,7 @@ defmodule PentoWeb.Router do get "/", PageController, :home live "/guess", WrongLive + resources "/products", ProductController end # Other scopes may use custom stacks.