def validate_primary_phone(self, attrs, source): international = attrs['international'] number = attrs[source] if international: validators.phone_international(number) else: validators.phone_domestic(number) return attrs
def validate_secondary_phone(self, attrs, source): number = attrs.get(source) international = attrs['international'] if number: if international: validators.phone_international(number) else: validators.phone_domestic(number) return attrs
def validate(self, data): international = data.get('international') primary_phone = data.get('primary_phone') secondary_phone = data.get('secondary_phone') if primary_phone: if international: validators.phone_international(primary_phone) else: validators.phone_domestic(primary_phone) if secondary_phone: if international: validators.phone_international(secondary_phone) else: validators.phone_domestic(secondary_phone) return data
def validate_phone(phone, international): if international: validators.phone_international(phone) else: validators.phone_domestic(phone)