chore(service): SIRET is required
This commit is contained in:
parent
9d59a50cd4
commit
91c735a219
4 changed files with 11 additions and 5 deletions
|
@ -37,7 +37,7 @@ class Service < ApplicationRecord
|
|||
validates :nom, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :nom, uniqueness: { scope: :administrateur, message: 'existe déjà' }
|
||||
validates :organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :siret, siret_format: true, allow_nil: true
|
||||
validates :siret, siret_format: true
|
||||
validates :type_organisme, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :email, presence: { message: 'doit être renseigné' }, allow_nil: false
|
||||
validates :telephone, phone: { possible: true, allow_blank: true }
|
||||
|
|
|
@ -12,7 +12,7 @@ class SiretFormatValidator < ActiveModel::EachValidator
|
|||
LA_POSTE_SIREN = '356000000'
|
||||
|
||||
def format_is_valid(value)
|
||||
value.match?(/^\d{14}$/)
|
||||
value&.match?(/^\d{14}$/)
|
||||
end
|
||||
|
||||
def luhn_passed(value)
|
||||
|
|
|
@ -23,7 +23,13 @@
|
|||
= f.label :siret do
|
||||
Numéro SIRET
|
||||
%span.mandatory *
|
||||
= f.text_field :siret, placeholder: "14 chiffres"
|
||||
|
||||
%p.notice
|
||||
Veuillez saisir le numéro de SIRET de l'organisme dont ce service dépend.
|
||||
%br
|
||||
= link_to "➡ Rechercher le numéro SIRET sur « annuaire-entreprises.data.gouv.fr »", annuaire_link, target: "_blank"
|
||||
|
||||
= f.text_field :siret, placeholder: "14 chiffres", required: true
|
||||
|
||||
= render Dsfr::CalloutComponent.new(title: "Informations de contact") do |c|
|
||||
- c.body do
|
||||
|
|
|
@ -48,9 +48,9 @@ describe Service, type: :model do
|
|||
expect(subject).not_to be_valid
|
||||
end
|
||||
|
||||
it 'should be optional' do
|
||||
it 'should be required' do
|
||||
subject.siret = nil
|
||||
expect(subject).to be_valid
|
||||
expect(subject).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue