omniconf icon indicating copy to clipboard operation
omniconf copied to clipboard

Q: How to define a multi-valued nested configuration

Open anujsrc opened this issue 7 years ago • 3 comments

  • Version: 0.2.5
  • Type: Query/Clarification to understand if there is a better way to define multi-valued configs
  • Summary: Need to define a validated configuration for parameters that may take nested params, like-
    • [{:host "192.168.4.40" :port 9092}]
    • [6379 6380]

Currently, I am defining a type as :edn. Is there a better way to define such multi-valued parameters where constraint can be applied on each value, like- map keys in the first case and integers in the second case.

anujsrc avatar Mar 21 '17 04:03 anujsrc

From a logical standpoint, defining such values as :edn is probably the correct solution, because you are not giving a separate identity to each element of the collection. Perhaps, it would make sense to have something like :list-of, in addition to :nested, but that will create new complicated syntax and semantics for populating such values (e.g. --servers.0.host example.com). I will give it a thought.

Regarding the verification part, you can attach a :verifier to an EDN value and validate the types of the subelements manually. I know, it feels backward but this is the only solution available right now.

alexander-yakushev avatar Mar 21 '17 06:03 alexander-yakushev

Thanks @alexander-yakushev - as you mentioned, we can still attach a :verifier, so this is not a blocker. Shall we close this issue or keep it open as a feature request to see if it gets more votes?

anujsrc avatar Mar 21 '17 06:03 anujsrc

I will leave this issue open until I figure out if having a nested type for lists is doable and worth doing. Thanks for the idea, Anuj!

alexander-yakushev avatar Mar 21 '17 06:03 alexander-yakushev