Add constraints to GroupeInstructeur

This commit is contained in:
simon lehericey 2019-10-09 18:05:43 +02:00
parent 4b058001aa
commit 1fa149575c
2 changed files with 43 additions and 0 deletions

View file

@ -4,4 +4,9 @@ class GroupeInstructeur < ApplicationRecord
has_many :assign_tos
has_many :instructeurs, through: :assign_tos, dependent: :destroy
has_many :dossiers
validates :label, presence: { message: 'doit être renseigné' }, allow_nil: false
validates :label, uniqueness: { scope: :procedure, message: 'existe déjà' }
before_validation -> { label&.strip! }
end