Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed feature for issue #28

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/python/validators/name_validator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
import re
class NameValidator:
def is_valid(self, name):
return True
namePattern = "^[A-Z][a-z]{1,}$"

valid_name = True

if (name is None):
valid_name = False

if (name[0] != name[0].capitalize()):
valid_name = False

if (name.endswith(" ")):
valid_name = False

if " " in name:
splitted_name = name.split(" ")
for word in splitted_name:
if "-" in word:
dashed_words = word.split("-")
for dashed_word in dashed_words:
if not (re.match(namePattern, dashed_word)):
valid_name = False
else:
if not (re.match(namePattern, word)):
valid_name = False
return valid_name


myName = NameValidator()

print(myName.is_valid("John Doe Price"))