From 5f74c42a00eb9ace017c58d89c8a79295f99ef7c Mon Sep 17 00:00:00 2001 From: Daniel Tinivella Date: Fri, 9 Feb 2024 22:52:06 -0300 Subject: [PATCH] add routes to products --- lib/pento/catalog/product.ex | 1 + lib/pento_web/router.ex | 1 + 2 files changed, 2 insertions(+) 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.