コード例 #1
0
def validate_password(password):
    letter = False
    number = False
    up = False
    low = False
    for x in password:
        if x.isalpha():
            letter = True
        if x.isdigit():
            number = True
        if x.isupper():
            up = True
        if x.islower():
            low = True

    if letter is True and number is True and up is True and low is True:
        return password
    raise ValidationError("Enter valid password")
コード例 #2
0
def validate_title(title):
    for x in title:
        if x[0].isupper() and x.isalpha():
            return title
        raise ValidationError("Enter valid titel")
コード例 #3
0
def validate_gender(gender):
    if gender == 'male' or gender == 'female':
        return gender
    raise ValidationError("Enter valid gender")
コード例 #4
0
def validate_age(age):
    if age.isdigit():
        return age
    raise ValidationError("Enter valid age")
コード例 #5
0
def check_if_letter(word):
    if word.isalpha():
        return word
    raise ValidationError("Enter valid first_name or last_name")
コード例 #6
0
def validate_email(email):
    if "@" in email:
        return email
    raise ValidationError("Enter valid email")
コード例 #7
0
def validate_nickname(nickname):
    if nickname.islower():
        return nickname
    raise ValidationError("Enter valid nickname")