示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    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)
示例#4
0
def to_safe_name(name: str) -> str:
    """Convert text to be made BQ-compatible (alphanumeric + underscores)"""
    return regex_replace(r'\-|\.|:', "", name.replace(' ', '_'))
示例#5
0
 def _remove_quotes(self, string):
     return regex_replace(r'^[\'"]?([^\'"]+)[\'"]?', r'\1', string)
示例#6
0
 def _remove_quotes(self, string):
     return regex_replace(r'^[\'"]?([^\'"]+)[\'"]?', r'\1', string)