Skip to content

Commit eb7b833

Browse files
author
ChadKluck
committed
updated config.py to validate CommaDelimited parameters
1 parent 5705a7b commit eb7b833

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cli/config.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,13 +498,13 @@ def validate_parameter(self, value: str, param_def: Dict) -> bool:
498498
if allowed_values and value not in allowed_values:
499499
return {"reason": f"Value must be one of: {', '.join(allowed_values)}", "valid": False}
500500

501-
# Check AllowedPattern if defined
502-
allowed_pattern = param_def.get('AllowedPattern')
503-
if allowed_pattern and not re.match(allowed_pattern, value):
504-
return {"reason": f"Value must match pattern: {allowed_pattern}", "valid": False}
505-
506501
# Type-specific validations
507502
if param_type in ['String', 'AWS::SSM::Parameter::Value<String>']:
503+
# Check AllowedPattern if defined
504+
allowed_pattern = param_def.get('AllowedPattern')
505+
if allowed_pattern and not re.match(allowed_pattern, value):
506+
return {"reason": f"Value must match pattern: {allowed_pattern}", "valid": False}
507+
508508
min_length = int(param_def.get('MinLength', 0))
509509
# Handle MaxLength differently - if not specified, use None instead of infinity
510510
max_length = param_def.get('MaxLength')
@@ -535,6 +535,13 @@ def validate_parameter(self, value: str, param_def: Dict) -> bool:
535535
items = [item.strip() for item in value.split(',')]
536536
if not all(items):
537537
return {"reason": "CommaDelimitedList cannot contain empty items", "valid": False}
538+
539+
# Check AllowedPattern against each item if defined
540+
allowed_pattern = param_def.get('AllowedPattern')
541+
if allowed_pattern:
542+
for i, item in enumerate(items, 1):
543+
if not re.match(allowed_pattern, item):
544+
return {"reason": f"Element {i} ('{item}') must match pattern: {allowed_pattern}", "valid": False}
538545

539546
elif param_type == 'List<Number>':
540547
try:

0 commit comments

Comments
 (0)