Simplify SiretFormatValidator
We can remove nil checks as we never get nil values
This commit is contained in:
parent
4e4b7c617f
commit
9d18f4187c
1 changed files with 2 additions and 2 deletions
|
@ -14,12 +14,12 @@ class SiretFormatValidator < ActiveModel::EachValidator
|
||||||
LA_POSTE_SIREN = '356000000'
|
LA_POSTE_SIREN = '356000000'
|
||||||
|
|
||||||
def format_is_valid(value)
|
def format_is_valid(value)
|
||||||
value&.match?(/^\d{14}$/)
|
value.match?(/^\d{14}$/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def luhn_passed(value)
|
def luhn_passed(value)
|
||||||
# Do not enforce Luhn for La Poste SIRET numbers, the only exception to this rule
|
# Do not enforce Luhn for La Poste SIRET numbers, the only exception to this rule
|
||||||
value.present? && (siret_is_attached_to_la_poste(value) || (luhn_checksum(value) % 10 == 0))
|
siret_is_attached_to_la_poste(value) || (luhn_checksum(value) % 10 == 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
def siret_is_attached_to_la_poste(value)
|
def siret_is_attached_to_la_poste(value)
|
||||||
|
|
Loading…
Reference in a new issue