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
2016-05-24 15:43:05 +02:00
siret.delete!(' ') unless siret.nil?
2016-05-24 15:28:16 +02:00
end
2015-12-03 15:02:22 +01:00
end