9
9
10
10
import regex as re
11
11
12
- from cfnlint .helpers import FUNCTIONS
12
+ from cfnlint .helpers import FUNCTIONS , ensure_list , is_function
13
13
from cfnlint .jsonschema import ValidationError
14
14
from cfnlint .rules import CloudFormationLintRule
15
15
@@ -80,8 +80,8 @@ def maxLength(self, validator, mL, instance, schema):
80
80
return
81
81
# there are scenarios where Fn::Sub may not predictable so use
82
82
# best judgement
83
- if validator . is_type ( instance , "object" ) and len (instance ) == 1 :
84
- key = list ( instance . keys ())[ 0 ]
83
+ key , value = is_function (instance )
84
+ if key is not None :
85
85
if key == "Fn::Sub" :
86
86
value = instance [key ]
87
87
if isinstance (value , str ):
@@ -93,7 +93,7 @@ def maxLength(self, validator, mL, instance, schema):
93
93
validator , mL , self ._fix_sub_string (value [0 ]), schema
94
94
)
95
95
return
96
- if schema .get ("type" ) == "object" :
96
+ if "object" in ensure_list ( schema .get ("type" )) :
97
97
yield from self ._non_string_max_length (instance , mL )
98
98
99
99
# pylint: disable=unused-argument, arguments-renamed
@@ -105,8 +105,8 @@ def minLength(self, validator, mL, instance, schema):
105
105
106
106
# there are scenarios where Fn::Sub may not predictable so use
107
107
# best judgement
108
- if validator . is_type ( instance , "object" ) and len (instance ) == 1 :
109
- key = list ( instance . keys ())[ 0 ]
108
+ key , value = is_function (instance )
109
+ if key is not None :
110
110
if key == "Fn::Sub" :
111
111
value = instance [key ]
112
112
if isinstance (value , str ):
@@ -118,5 +118,6 @@ def minLength(self, validator, mL, instance, schema):
118
118
validator , mL , self ._fix_sub_string (value [0 ]), schema
119
119
)
120
120
return
121
- if schema .get ("type" ) == "object" :
121
+
122
+ if "object" in ensure_list (schema .get ("type" )):
122
123
yield from self ._non_string_min_length (instance , mL )
0 commit comments