The “Give It a Try” exercise “Use Schemaless Changesets" challenges the reader to add a search by product SKU capability. The search form should validate SKUs:
Assuming that all product SKUs have at least 7 digits, ensure that the form validates the SKU input and displays errors when provided with an invalid SKU.
The “at least 7 digits” assumption is false. The first product has SKU 123456. The book showed how to add this product to the database on pages 75-76:
iex> attrs = %{
name: "Pentominoes",
sku: 123456,
unit_price: 5.00,
description: "A super fun game!"
}
...
iex> Product.changeset(product, attrs)
...
iex> Product.changeset(product, attrs) |> Repo.insert()