demarches-normaliennes/app/models/siret.rb

16 lines
298 B
Ruby
Raw Normal View History

2015-12-03 15:02:22 +01:00
class Siret
include ActiveModel::Model
2016-05-24 15:28:16 +02:00
include ActiveModel::Validations::Callbacks
2015-12-03 15:02:22 +01:00
attr_accessor :siret
validates_presence_of :siret
validates :siret, siret_format: true
2016-05-24 15:28:16 +02:00
before_validation :remove_whitespace
def remove_whitespace
2018-01-11 19:04:39 +01:00
siret.delete!(' ') if siret.present?
2016-05-24 15:28:16 +02:00
end
2015-12-03 15:02:22 +01:00
end