From c9b78da3af46effb9b6e66de5a6000974de93ae4 Mon Sep 17 00:00:00 2001 From: Luca Favatella Date: Tue, 7 Mar 2017 23:12:45 +0000 Subject: [PATCH] Enforce that schema has at least a field with at least `id` attribute This change is in the context of highlighting in sumo_rest the role of the `:id` binding in the cowboy route. --- src/sumo_internal.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sumo_internal.erl b/src/sumo_internal.erl index 105ca65..5314bc4 100644 --- a/src/sumo_internal.erl +++ b/src/sumo_internal.erl @@ -85,7 +85,9 @@ %% @doc Returns a new schema. -spec new_schema(sumo:schema_name(), [field()]) -> schema(). new_schema(Name, Fields) -> - #{name => Name, fields => Fields}. + S = #{name => Name, fields => Fields}, + _ = get_id_field(S), + S. %% @doc Returns a new field of the given type and attributes. -spec new_field(