demarches-normaliennes/app/models/siret.rb

16 lines
302 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
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-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