Use this rule to control that the YAML documents for a specified key, only contain int values within a specified range. The range can be defined with a minimum and a maximum value. The specific key can be defined with a regular expression and the location of the key can be defined with two ancestor regular expressions.
.*. The start and end line markers ^ and $ are implicit: this means that
setting foo is equivalent to ^foo$.:) and always start with an implicit <root> parent.
So, the ancestor string for a connectionTimeout key could be: <root>:spring:datasource:hikari.
If the includedAncestors regex matches the ancestor string of the key, the value is range checked.
The start and end line markers ^ and $ are implicit, just like the key regex.
Leave empty for no ancestor matching.^ and $ are implicit, just like the key regex.
Leave empty for no ancestor matching.With:
key-name = connect(ion)?-?[tT]imeout.*
included-ancestors = <root>:[a-z\\-]+service[a-z0-9\\-]+:[a-z\\-]+endpoint[a-z0-9\\-]+
excluded-ancestors = .*datasource:hikari
minValue = 50
maxValue = 699
the following code snippet would PASS:
my-service-2:
my-endpoint-2:
connectionTimeout: 600 # no violation
spring:
datasource:
hikari:
connectionTimeout: 5000 # no violation
the following code snippet would FAIL:
my-service-1:
my-endpoint-1:
connectionTimeout: 700 # violation, > 699 ms