mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
11 lines
343 B
Ruby
11 lines
343 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
# Validates there's only one database provider
|
||
|
class DatabaseProviderValidator < ActiveModel::Validator
|
||
|
def validate(record)
|
||
|
return if DatabaseProvider.count.zero?
|
||
|
|
||
|
record.errors[:id] << I18n.t('app.admin.authentication_new.a_local_database_provider_already_exists_unable_to_create_another')
|
||
|
end
|
||
|
end
|