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
|
|
|
|
|
2018-03-06 13:44:29 +01:00
|
|
|
validates :siret, presence: true
|
2015-12-03 15:02:22 +01:00
|
|
|
validates :siret, siret_format: true
|
2016-05-24 15:28:16 +02:00
|
|
|
|
|
|
|
before_validation :remove_whitespace
|
|
|
|
|
|
|
|
def remove_whitespace
|
2018-10-01 13:24:37 +02:00
|
|
|
if siret.present?
|
|
|
|
siret.delete!(' ')
|
|
|
|
end
|
2016-05-24 15:28:16 +02:00
|
|
|
end
|
2015-12-03 15:02:22 +01:00
|
|
|
end
|