Class: ActiveModel::Validations::SiretValidator

Inherits:
EachValidator
  • Object
show all
Defined in:
lib/siret_validator.rb

Constant Summary collapse

LA_POSTE_SIREN =
"356000000"
LA_POSTE_SIRET_SIEGE =
"35600000000048"

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/siret_validator.rb', line 13

def validate_each(record, attribute, value)
  if !valid_format?(value)
    record.errors.add(attribute, :wrong_siret_format, **options)
  elsif !valid_checksum?(value)
    record.errors.add(attribute, :invalid, **options)
  end
end