diff --git a/app/models/authentication.rb b/app/models/authentication.rb index b601a39e34a..87069905bb9 100644 --- a/app/models/authentication.rb +++ b/app/models/authentication.rb @@ -45,6 +45,8 @@ def self.new(*args, &block) include OwnershipMixin include TenancyMixin + validates :name, :length => {:maximum => 128} + belongs_to :tenant # TODO: DELETE ME!!!! diff --git a/app/models/cloud_tenant.rb b/app/models/cloud_tenant.rb index 5e910879ff2..a808007e955 100644 --- a/app/models/cloud_tenant.rb +++ b/app/models/cloud_tenant.rb @@ -30,6 +30,8 @@ class CloudTenant < ApplicationRecord has_many :flavors, :through => :cloud_tenant_flavors has_many :cloud_volume_types, :through => :ext_management_system + validates :name, :length => {:maximum => 128} + alias_method :direct_cloud_networks, :cloud_networks acts_as_miq_taggable diff --git a/app/models/cloud_volume_snapshot.rb b/app/models/cloud_volume_snapshot.rb index 2fab9887c47..8f5cc6a1278 100644 --- a/app/models/cloud_volume_snapshot.rb +++ b/app/models/cloud_volume_snapshot.rb @@ -15,6 +15,8 @@ class CloudVolumeSnapshot < ApplicationRecord virtual_total :total_based_volumes, :based_volumes + validates :description, :length => {:maximum => 50} + def self.class_by_ems(ext_management_system) ext_management_system&.class_by_ems(:CloudVolumeSnapshot) end diff --git a/app/models/generic_object.rb b/app/models/generic_object.rb index dc862e99356..2e1d8a51286 100644 --- a/app/models/generic_object.rb +++ b/app/models/generic_object.rb @@ -10,7 +10,7 @@ class GenericObject < ApplicationRecord has_one :picture, :through => :generic_object_definition has_many :custom_button_events, :foreign_key => :target_id, :dependent => :destroy - validates :name, :presence => true + validates :name, :presence => true, :length => {:maximum => 255} delegate :property_attribute_defined?, :property_defined?, diff --git a/app/models/miq_alert.rb b/app/models/miq_alert.rb index e079c27c107..b362fc7b0c5 100644 --- a/app/models/miq_alert.rb +++ b/app/models/miq_alert.rb @@ -9,6 +9,7 @@ class MiqAlert < ApplicationRecord serialize :options validates :description, :presence => true, :uniqueness_when_changed => true, :length => {:maximum => 255} + validates :name, :length => {:maximum => 512} validate :validate_automate_expressions validate :validate_single_expression validates :severity, :inclusion => {:in => SEVERITIES} diff --git a/app/models/pxe_image.rb b/app/models/pxe_image.rb index 136cf95a895..82d9795737e 100644 --- a/app/models/pxe_image.rb +++ b/app/models/pxe_image.rb @@ -5,6 +5,8 @@ class PxeImage < ApplicationRecord has_many :customization_templates, :through => :pxe_image_type + validates :name, :length => {:maximum => 255} + acts_as_miq_taggable before_validation do diff --git a/app/models/service.rb b/app/models/service.rb index d9c8dc56997..61c669056b8 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -87,7 +87,8 @@ class Service < ApplicationRecord virtual_column :power_state, :type => :string virtual_column :power_status, :type => :string - validates :name, :presence => true + validates :name, :presence => true, :length => {:maximum => 256} + validates :description, :length => {:maximum => 1024} default_value_for :visible, false default_value_for :initiator, 'user' diff --git a/app/models/time_profile.rb b/app/models/time_profile.rb index 6ddbc001a62..3f9adbc75df 100644 --- a/app/models/time_profile.rb +++ b/app/models/time_profile.rb @@ -7,6 +7,8 @@ class TimeProfile < ApplicationRecord default_value_for :days, ALL_DAYS default_value_for :hours, ALL_HOURS + validates :description, :length => {:maximum => 128} + has_many :miq_reports has_many :metric_rollups diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index 1d6a1c7e283..9faffabee45 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -61,7 +61,10 @@ class VmOrTemplate < ApplicationRecord POWER_OPS = %w[start stop suspend reset shutdown_guest standby_guest reboot_guest] REMOTE_REGION_TASKS = POWER_OPS + %w[retire_now] - validates_presence_of :name, :location + # NOTE: different react forms set a maxLength of 50 or 128 + validates :name, :presence => true, :length => {:maximum => 128} + validates :description, :length => {:maximum => 100} + validates :location, :presence => true validates :vendor, :inclusion => {:in => VENDOR_TYPES.keys} has_one :operating_system, :dependent => :destroy diff --git a/app/models/zone.rb b/app/models/zone.rb index d8a4b0403f4..fdb909abe31 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -1,6 +1,6 @@ class Zone < ApplicationRecord - validates_presence_of :name, :description - validates :name, :unique_within_region => true + validates :name, :unique_within_region => true, :presence => true, :length => {:maximum => 128} + validates :description, :presence => true, :length => {:maximum => 128} serialize :settings, :type => Hash