mirror of
https://github.com/adrienverge/yamllint.git
synced 2024-11-22 07:36:25 -06:00
config: Allow rules to validate their configuration
This commit is contained in:
parent
483a8d89a5
commit
851d34b9fd
@ -177,6 +177,12 @@ def validate_rule_conf(rule, conf):
|
||||
for optkey in options:
|
||||
if optkey not in conf:
|
||||
conf[optkey] = options_default[optkey]
|
||||
|
||||
if hasattr(rule, 'VALIDATE'):
|
||||
res = rule.VALIDATE(conf)
|
||||
if res:
|
||||
raise YamlLintConfigError('invalid config: %s: %s' %
|
||||
(rule.ID, res))
|
||||
else:
|
||||
raise YamlLintConfigError(('invalid config: rule "%s": should be '
|
||||
'either "enable", "disable" or a dict')
|
||||
|
Loading…
Reference in New Issue
Block a user