Beispiel #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
Beispiel #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
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
Beispiel #4
0
def could_be_number(value):
    if is_possible_number(value) is False:
        raise ValidationError("Not a phone number")
Beispiel #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')
Beispiel #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.")
Beispiel #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
Beispiel #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"
        )
Beispiel #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')