You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to avoid a schema-less "data bag" situation when using maps, it seems to be a good practice to use #{a => A} only in one place when initially creating a map. Fields expected to be used in the future should be explicitly assigned undefined (or some other sentinel value) to mark that their presence is expected. After that only #{a := A'} should be used for updating values of existing fields and => should not be used again. That way for each "kind" of map there's one place in code defining what fields should be present in the map.
The Elvis rule would find all map update operations (i.e. M#{a := A'}) and ensure none of them use => for updating the map.
The text was updated successfully, but these errors were encountered:
It seems some of the things you refer can be dealt with by dialyzer already, namely the expected content/format of a map. If you want a compulsory field set as undefined, you can use notation #{ FieldName :: binary() := undefined | pos_integer()}, for example.
In order to avoid a schema-less "data bag" situation when using maps, it seems to be a good practice to use
#{a => A}
only in one place when initially creating a map. Fields expected to be used in the future should be explicitly assignedundefined
(or some other sentinel value) to mark that their presence is expected. After that only#{a := A'}
should be used for updating values of existing fields and=>
should not be used again. That way for each "kind" of map there's one place in code defining what fields should be present in the map.The Elvis rule would find all map update operations (i.e.
M#{a := A'}
) and ensure none of them use=>
for updating the map.The text was updated successfully, but these errors were encountered: