def validate(self, data): field = data['field'] try: data['value'] = scrub_field(field, data['value']) except ValueError as exc: raise serializers.ValidationError('Scrubber for %r failed: %s' % (field, exc)) from exc if field == 'phone': country_code = parse_phone_number(data['value'], get_current_cc()).country_code if country_code in settings.SMS_BLACKLISTED_COUNTRIES: raise serializers.ValidationError('This country code (+%d) is not available at this time.' % country_code) return data
def test_activated(self): with translation.override('en-au'): assert get_current_cc() == 'AU'
def test_explicit(self): assert get_current_cc('en-us') == 'US'
def test_from_default(self): assert get_current_cc() == 'DE'
def test_activated(self): with translation.override("en-au"): assert get_current_cc() == "AU"
def test_explicit(self): assert get_current_cc("en-us") == "US"
def test_from_default(self): assert get_current_cc() == "DE"