def clean(self, value): super(PTPhoneNumberField, self).clean(value) if value in EMPTY_VALUES: return '' value = regex_replace('(\.|\s)', '', smart_text(value)) match = PHONE_NUMBER_REGEX.search(value) if not match: raise ValidationError(self.error_messages['invalid']) return '{0}'.format(value)
def clean(self, value): super(PTPhoneNumberField, self).clean(value) if value in EMPTY_VALUES: return '' value = regex_replace('(\.|\s)', '', force_text(value)) match = PHONE_NUMBER_REGEX.search(value) if not match: raise ValidationError(self.error_messages['invalid']) return '{0}'.format(value)
def clean(self, value): super(PTPhoneNumberField, self).clean(value) if value in EMPTY_VALUES: return "" value = regex_replace("(\.|\s)", "", force_text(value)) match = PHONE_NUMBER_REGEX.search(value) if not match: raise ValidationError(self.error_messages["invalid"]) return "{0}".format(value)
def to_safe_name(name: str) -> str: """Convert text to be made BQ-compatible (alphanumeric + underscores)""" return regex_replace(r'\-|\.|:', "", name.replace(' ', '_'))
def _remove_quotes(self, string): return regex_replace(r'^[\'"]?([^\'"]+)[\'"]?', r'\1', string)