2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-10-16 17:25:06 +02:00
|
|
|
class DataFixer::ChampsPhoneInvalid
|
2023-10-12 15:39:08 +02:00
|
|
|
def self.fix(phones_string)
|
|
|
|
phone_candidates = phones_string
|
|
|
|
.split(/-/)
|
|
|
|
.map { |phone_with_space| phone_with_space.gsub(/\s/, '') }
|
|
|
|
|
|
|
|
phone_candidates.find { |phone| phone.start_with?(/0(6|7)/) } || phone_candidates.first
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.fixable?(phones_string)
|
|
|
|
/-/.match?(phones_string)
|
|
|
|
end
|
|
|
|
end
|