demarches-normaliennes/app/models/champs/phone_champ.rb
2024-08-22 09:26:48 +02:00

11 lines
386 B
Ruby

# frozen_string_literal: true
class Champs::PhoneChamp < Champs::TextChamp
validates :value,
phone: {
possible: true,
allow_blank: true,
message: I18n.t(:not_a_phone, scope: 'activerecord.errors.messages')
},
if: -> { !Phonelib.valid_for_countries?(value, TypesDeChamp::PhoneTypeDeChamp::DEFAULT_COUNTRY_CODES) && validate_champ_value_or_prefill? }
end