@@ -35,8 +35,8 @@ def load_policies_yaml(policies_yaml):
3535
3636def load_policies_file (policies_file , validate = True ):
3737 """
38- Load provided ``policies_file`` into a Python dictionary.
39- The policies format is validated by default.
38+ Load provided ``policies_file`` into a Python dictionary. The policies format
39+ is validated by default to ensure at least one policy type exists .
4040 """
4141 policies_dict = load_policies_yaml (policies_yaml = policies_file .read_text ())
4242 if validate :
@@ -45,13 +45,23 @@ def load_policies_file(policies_file, validate=True):
4545
4646
4747def validate_policies (policies_dict ):
48- """Return True if the provided ``policies_dict`` is valid."""
48+ """
49+ Return True if the provided ``policies_dict`` contains at least
50+ one supported policy type.
51+ """
4952 if not isinstance (policies_dict , dict ):
5053 raise ValidationError ("The `policies_dict` argument must be a dictionary." )
5154
52- if "license_policies" not in policies_dict :
55+ supported_keys = {
56+ "license_policies" ,
57+ "license_clarity_thresholds" ,
58+ "scorecard_score_thresholds" ,
59+ }
60+
61+ if not any (key in policies_dict for key in supported_keys ):
5362 raise ValidationError (
54- "The `license_policies` key is missing from provided policies data."
63+ "At least one of the following policy types must be present: "
64+ f"{ ', ' .join (sorted (supported_keys ))} "
5565 )
5666
5767 return True
0 commit comments