Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set model validation lengths based upon react form maxLength #23262

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def self.new(*args, &block)
include OwnershipMixin
include TenancyMixin

validates :name, :length => {:maximum => 128}

belongs_to :tenant

# TODO: DELETE ME!!!!
Expand Down
2 changes: 2 additions & 0 deletions app/models/cloud_tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/models/cloud_volume_snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/generic_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?,
Expand Down
1 change: 1 addition & 0 deletions app/models/miq_alert.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 2 additions & 0 deletions app/models/pxe_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions app/models/time_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/zone.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading