Ticket #2307: phoneNumberField.diff

File phoneNumberField.diff, 2.0 KB (added by Wiliam Alves de Souza <wiliamsouza83@…>, 18 years ago)

Other solution

  • django/conf/locale/pt_BR/LC_MESSAGES/django.po

     
    17291729#, python-format
    17301730msgid "Phone numbers must be in XXX-XXX-XXXX format. \"%s\" is invalid."
    17311731msgstr ""
    1732 "Números de telefone deves estar no formato XXX-XXX-XXXX.\"%s\" é inválido."
     1732"Números de telefone devem estar no formato XX-XXXX-XXXX.\"%s\" é inválido."
    17331733
    17341734#: core/validators.py:167
    17351735#, python-format
  • django/core/validators.py

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
     
    1212from django.conf import settings
    1313from django.utils.translation import gettext, gettext_lazy, ngettext
    1414from django.utils.functional import Promise, lazy
     15from django.core import regex
     16import settings
    1517import re
    1618
    1719_datere = r'\d{4}-\d{1,2}-\d{1,2}'
     
    2729    r')@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$', re.IGNORECASE)  # domain
    2830integer_re = re.compile(r'^-?\d+$')
    2931ip4_re = re.compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}$')
    30 phone_re = re.compile(r'^[A-PR-Y0-9]{3}-[A-PR-Y0-9]{3}-[A-PR-Y0-9]{4}$', re.IGNORECASE)
    3132slug_re = re.compile(r'^[-\w]+$')
    3233url_re = re.compile(r'^https?://\S+$')
    3334
     
    184185        raise ValidationError, gettext("The URL %s does not point to a valid image.") % field_data
    185186
    186187def isValidPhone(field_data, all_data):
     188    lang = settings.LANGUAGE_CODE.replace('-', '_')
     189    phone_re = getattr(regex, 'phone_%s' % lang, regex.phone_en_us)
    187190    if not phone_re.search(field_data):
    188191        raise ValidationError, gettext('Phone numbers must be in XXX-XXX-XXXX format. "%s" is invalid.') % field_data
    189192
Back to Top