Skip to content

Commit b07e4d3

Browse files
committed
add doc for validate!/1 and validate/1
1 parent d4cb559 commit b07e4d3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/scenic/themes.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ defmodule Scenic.Themes do
111111
end
112112
end
113113

114+
@doc """
115+
Validates a theme, raises when an invalid themes is passed in.
116+
"""
114117
def validate!(theme)
115118
def validate!({lib, theme_name} = lib_theme) when is_atom(theme_name) do
116119
themes = module().library()
@@ -256,6 +259,9 @@ defmodule Scenic.Themes do
256259
end)
257260
end
258261

262+
@doc """
263+
Validates a theme, returns `{:ok, theme}` on a valid theme or `{:error, :error_type}` on an invalid theme.
264+
"""
259265
def validate(theme)
260266
def validate({lib, theme_name} = lib_theme) when is_atom(theme_name) do
261267
themes = module().library()
@@ -318,22 +324,22 @@ defmodule Scenic.Themes do
318324
_, {:error, msg} ->
319325
{:error, msg}
320326

321-
{key, color}, {:ok, _} = acc ->
327+
{_key, color}, {:ok, _} = acc ->
322328
case Color.validate(color) do
323329
{:ok, _} -> acc
324-
{:error, msg} -> {:error, :invalid_color}
330+
{:error, _msg} -> {:error, :invalid_color}
325331
end
326332
end)
327333
end
328334

329-
def validate(%{} = map) do
335+
def validate(%{} = _map) do
330336
{
331337
:error,
332338
:missing_key
333339
}
334340
end
335341

336-
def validate(data) do
342+
def validate(_data) do
337343
{
338344
:error,
339345
:invalid

0 commit comments

Comments
 (0)