diff --git a/app/models/authentication.rb b/app/models/authentication.rb index b601a39e34ac..5c28c3f998ba 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, :presence => true, :length => {:maximum => 128} + belongs_to :tenant # TODO: DELETE ME!!!! diff --git a/app/models/cloud_tenant.rb b/app/models/cloud_tenant.rb index 5e910879ff2d..a808007e9557 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 2fab9887c475..8f5cc6a12783 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 dc862e993564..2e1d8a51286a 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 e079c27c107d..7743cd4e8180 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 :notes, :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 136cf95a8951..82d9795737ee 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/time_profile.rb b/app/models/time_profile.rb index 6ddbc001a623..3f9adbc75df2 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 1d6a1c7e283e..9faffabee452 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 a15d93500736..9ff847eaa93b 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -1,8 +1,7 @@ class Zone < ApplicationRecord - validates_presence_of :name, :description - validates :name, :unique_within_region => true - serialize :settings, Hash + validates :name, :unique_within_region => true, :presence => true, :length => {:maximum => 50} + validates :description, :presence => true, :length => {:maximum => 50} belongs_to :log_file_depot, :class_name => "FileDepot"