hapipal / confidence

Dynamic, declarative configurations
Other
264 stars 44 forks source link

Either allow matching "$undefined" or any non-falsy criteria value #77

Closed csabapalfi closed 5 years ago

csabapalfi commented 6 years ago

Currently there's no way to only have a $default value if the filtered criteria is undefined.

e.g.

{
  "$filter": "env.canBeUndefined",
  "$default": "env:canBeUndefined",
  "$undefined": "defaultValue"
}

(env: is shortstop syntax to get an env var)

We could also just have $truthy,$falsy,$null, etc but that's probably taking it too far.

An alternative to this is just manipulating criteria before passing it in but we just want to use process.env as it is.

I think #67 is about pretty much the same thing but in a different way.

augnin commented 5 years ago

hey @csabapalfi .. v4.0 handles a lot of this scenarios with $env and $param directives. have a look at the documentation and test cases. I am closing this for now. feel free to open this issue again, in case you think something is missing.