diff --git a/ro_help/hub/migrations/0044_auto_20200404_1000.py b/ro_help/hub/migrations/0044_auto_20200404_1000.py new file mode 100644 index 00000000..a87fe4a5 --- /dev/null +++ b/ro_help/hub/migrations/0044_auto_20200404_1000.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.4 on 2020-04-04 10:00 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hub', '0043_auto_20200404_0914'), + ] + + operations = [ + migrations.AlterField( + model_name='ngo', + name='phone', + field=models.CharField(max_length=30, validators=[django.core.validators.RegexValidator(message='Enter a valid phone number', regex='^(\\+4|)?(07[0-8]{1}[0-9]{1}|02[0-9]{2}|03[0-9]{2}){1}?(\\s|\\.|\\-)?([0-9]{3}(\\s|\\.|\\-|)){2}$')], verbose_name='Phone'), + ), + ] diff --git a/ro_help/hub/models.py b/ro_help/hub/models.py index af7fffc9..a8fb0f15 100644 --- a/ro_help/hub/models.py +++ b/ro_help/hub/models.py @@ -199,7 +199,16 @@ class NGO(TimeStampedModel): description = models.TextField(_("Description")) contact_name = models.CharField(_("Contact person's name"), max_length=254) email = models.EmailField(_("Email"),) - phone = models.CharField(_("Phone"), max_length=30) + phone = models.CharField( + _("Phone"), + max_length=30, + validators=[ + RegexValidator( + regex="^(\+4|)?(07[0-8]{1}[0-9]{1}|02[0-9]{2}|03[0-9]{2}){1}?(\s|\.|\-)?([0-9]{3}(\s|\.|\-|)){2}$", + message=_("Enter a valid phone number"), + ), + ] + ) address = models.CharField(_("Address"), max_length=400) cif = models.CharField("CIF", max_length=20, null=True, blank=True) cui = models.CharField("CUI", max_length=20, null=True, blank=True)