has been parsed and read into an implicit of type Config, then we are
able to validate that the value at the path test.nestedVal has type
Double and that it satisfies specified size bounds as follows:
caseobject ShouldBeAPercentageValue extends Exception
validate[Double]("test.nestedVal", ShouldBeAPercentageValue)(n =>0 <= n && n <= 100)
If the configuration value at path test.nestedVal fails to pass the
percentage bounds check, then Left(ShouldBeAPercentageValue) is
returned.
Likewise, we can enforce that all values in the array at the path
test.context.valueStrList match the regular expression pattern
[a-z0-9]+:[0-9]+ as follows:
Using Typesafe config we read in and parse configuration files. Paths into these files are then retrieved and type checked using Ficus.
Using a lightweight DSL, we are able to then check and validate these type checked values. For example, given that the Typesafe configuration:
has been parsed and read into an implicit of type
Config
, then we are able to validate that the value at the pathtest.nestedVal
has typeDouble
and that it satisfies specified size bounds as follows:If the configuration value at path
test.nestedVal
fails to pass the percentage bounds check, thenLeft(ShouldBeAPercentageValue)
is returned.Likewise, we can enforce that all values in the array at the path
test.context.valueStrList
match the regular expression pattern[a-z0-9]+:[0-9]+
as follows:In some instances, we may not care about checking the value at a configuration path. In these cases we can use
unchecked
:unchecked[FiniteDuration]("test.nestedDuration")