Fakultas Ilmu Komputer UI

Commit bd6fa318 authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[GREEN] Add custom phone validator on Account model

parent e1abf1fe
Pipeline #46125 passed with stages
in 26 minutes and 53 seconds
import uuid
from django.contrib.auth.models import User
from django.db import models
from django.core.validators import RegexValidator
from apps.commons.managers import SoftDeleteManager
from apps.commons.models import HistoryEnabledModel, HistoryModel
......@@ -32,7 +33,15 @@ class Account(HistoryEnabledModel):
user = models.OneToOneField(User, on_delete=models.CASCADE)
name = models.CharField(max_length=128)
email = models.EmailField(max_length=128)
phone_number = models.CharField(max_length=64)
phone_number = models.CharField(
max_length=64,
validators=[
RegexValidator(
regex=r'^\+?\d{9,15}$',
message=('Phone number has 9-15 digits, allowed to have + prefix'),
),
]
)
area = models.CharField(max_length=128)
is_admin = models.BooleanField(default=False)
is_verified = models.BooleanField(default=False)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment