Skip to content

Commit

Permalink
Validate parameter options based on Type
Browse files Browse the repository at this point in the history
  • Loading branch information
phobologic committed Aug 22, 2015
1 parent c48dd96 commit bc2898c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions troposphere/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,23 @@ class Parameter(AWSDeclaration):
'Description': (basestring, False),
'ConstraintDescription': (basestring, False),
}

def validate(self):
if self.properties['Type'] == 'String':
if 'AllowedPattern' in self.properties:
raise ValueError("AllowedPattern can only be used with "
"parameters of the String type.")
if 'MaxLength' in self.properties:
raise ValueError("MaxLength can only be used with "
"parameters of the String type.")
if 'MinLength' in self.properties:
raise ValueError("MinLength can only be used with "
"parameters of the String type.")
if self.properties['Type'] == 'Number':
if 'MaxValue' in self.properties:
raise ValueError("MaxValue can only be used with "
"parameters of the Number type.")
if 'MinValue' in self.properties:
raise ValueError("MinValue can only be used with "
"parameters of the Number type.")

0 comments on commit bc2898c

Please sign in to comment.