old_contents: # -*- coding: utf-8 -*-
  
  from __future__ import unicode_literals
  
  from django.core.exceptions import ValidationError
  from django.utils.translation import ugettext_lazy as _
  
  from phonenumber_field.phonenumber import to_python
  
  
  def validate_international_phonenumber(value):
      phone_number = to_python(value)
      if phone_number and not phone_number.is_valid():
          raise ValidationError(_('The phone number entered is not valid.'))
  
new_contents: # -*- coding: utf-8 -*-
  
  from __future__ import unicode_literals
  
  from django.core.exceptions import ValidationError
  from django.utils.translation import ugettext_lazy as _
  
  from phonenumber_field.phonenumber import to_python
  
  
  def validate_international_phonenumber(value):
      phone_number = to_python(value)
      if phone_number and not phone_number.is_valid():
          raise ValidationError(
              _('The phone number entered is not valid.'),
              code='invalid_phone_number')
  
subject: add error code to validation