Ejemplo n.º 1
0
def clean_phone_for_country(phone, country):
    error = _("The phone number entered is not valid.")
    error_code = "invalid_phone_number"
    if phone:
        try:
            phone = PhoneNumber.from_string(phone, country)
        except NumberParseException:
            raise forms.ValidationError(error, code=error_code)
        else:
            if not is_possible_number(phone):
                raise forms.ValidationError(error, code=error_code)
    return phone
Ejemplo n.º 2
0
def clean_phone_for_country(phone, country):
    error = _("The phone number entered is not valid.")
    error_code = "invalid_phone_number"
    if phone:
        try:
            phone = PhoneNumber.from_string(phone, country)
        except NumberParseException:
            raise forms.ValidationError(error, code=error_code)
        else:
            if not is_possible_number(phone):
                raise forms.ValidationError(error, code=error_code)
    return phone
Ejemplo n.º 3
0
def validate_possible_number(phone, country=None):
    phone_number = to_python(phone, country)
    if (phone_number and not is_possible_number(phone_number)
            or not phone_number.is_valid()):
        raise ValidationError("Введенный номер телефона недействителен", )
    return phone_number
Ejemplo n.º 4
0
def could_be_number(value):
    if is_possible_number(value) is False:
        raise ValidationError("Not a phone number")
Ejemplo n.º 5
0
def validate_possible_number(value):
    phone_number = to_python(value)
    if phone_number and not is_possible_number(phone_number):
        raise ValidationError(
            _('The phone number entered is not valid.'),
            code='invalid_phone_number')
Ejemplo n.º 6
0
def validate_possible_number(value):
    phone_number = to_python(value)
    if phone_number and not is_possible_number(phone_number):
        raise ValidationError("The phone number entered is not valid.")
Ejemplo n.º 7
0
def validate_possible_number(phone):
    phone_number = to_python(phone, "ID")
    if phone_number and not is_possible_number(
            phone_number) or not phone_number.is_valid():
        raise ValidationError("The phone number entered is not valid.")
    return phone_number
Ejemplo n.º 8
0
def validate_possible_number(value, country=None):
    phone_number = to_python(value, country)
    if phone_number and not is_possible_number(phone_number):
        raise ValidationError(
            _("The phone number entered is not valid."), code="invalid_phone_number"
        )
Ejemplo n.º 9
0
def validate_possible_number(value):
    phone_number = to_python(value)
    if phone_number and not is_possible_number(phone_number):
        raise ValidationError(
            _('The phone number entered is not valid.'),
            code='invalid_phone_number')