Skip to content

Commit

Permalink
Added the common directory - common files and functions between all t…
Browse files Browse the repository at this point in the history
…he patterns
  • Loading branch information
Mohanna Shahrad committed Aug 25, 2022
1 parent 87a37ed commit 3b1bade
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cloud_templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
aws_cdk/common/__pycache__/
Empty file.
31 changes: 31 additions & 0 deletions cloud_templates/aws_cdk/common/customExceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class NoSQL(Exception):

def __init__(self):
self.message = "No sql statemtnt is provided. Please refer to README.md for more information."

def __str__(self):
return(repr(self.message))

class NoTimestreamDimension(Exception):

def __init__(self):
self.message = "No dimesnsion is provided. Each record contains an array of dimensions (minimum 1).Please refer to README.md for more information."

def __str__(self):
return(repr(self.message))

class WrongLengthForInput(Exception):

def __init__(self, message):
self.message = message

def __str__(self):
return(repr(self.message))

class WrongFormattedInput(Exception):

def __init__(self, message):
self.message = message

def __str__(self):
return(repr(self.message))
10 changes: 10 additions & 0 deletions cloud_templates/aws_cdk/common/inputValidation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import re
from common.customExceptions import *

def checkInputLength(self, min_length, max_length, input, resource_name):
if len(input) < min_length or len(input) > max_length:
raise WrongLengthForInput(f"Invalid input length for {resource_name}'s name. Check the README.md file for more details.")

def checkInputPattern(self, pattern, input, resource_name):
if not re.match(pattern, input):
raise WrongFormattedInput(f"Invalid input pattern for {resource_name}'s name. Check the README.md file for more details.")

0 comments on commit 3b1bade

Please sign in to comment.