fix mobile number detection

online_reg^2
Raz 11 months ago
parent dfaa18d9e6
commit fc3708fbc3
  1. 3
      PadelClub/Extensions/String+Extensions.swift
  2. 4
      PadelClub/Views/Calling/Components/PlayersWithoutContactView.swift

@ -166,8 +166,7 @@ extension String {
// MARK: - FFT Source Importing // MARK: - FFT Source Importing
extension String { extension String {
enum RegexStatic { enum RegexStatic {
static let mobileNumber = /^0[6-7]/ static let mobileNumber = /^(?:\+33|0033|0)[6-7](?:[ .-]?[0-9]{2}){4}$/
//static let mobileNumber = /^(?:(?:\+|00)33[\s.-]{0,3}(?:\(0\)[\s.-]{0,3})?|0)[1-9](?:(?:[\s.-]?\d{2}){4}|\d{2}(?:[\s.-]?\d{3}){2})$/
} }
func isMobileNumber() -> Bool { func isMobileNumber() -> Bool {

@ -31,7 +31,7 @@ struct PlayersWithoutContactView: View {
} }
} }
let withoutPhones = players.filter({ $0.phoneNumber?.isEmpty == true || $0.phoneNumber == nil }) let withoutPhones = players.filter({ $0.phoneNumber?.isEmpty == true || $0.phoneNumber == nil || $0.phoneNumber?.isMobileNumber() == false })
DisclosureGroup { DisclosureGroup {
ForEach(withoutPhones) { player in ForEach(withoutPhones) { player in
NavigationLink { NavigationLink {
@ -45,7 +45,7 @@ struct PlayersWithoutContactView: View {
LabeledContent { LabeledContent {
Text(withoutPhones.count.formatted()) Text(withoutPhones.count.formatted())
} label: { } label: {
Text("Joueurs sans téléphone") Text("Joueurs sans téléphone portable")
} }
} }
} header: { } header: {

Loading…
Cancel
Save