Skip to content

Commit e4dca87

Browse files
committed
Set model validation lengths based upon react form maxLength
1 parent 66de366 commit e4dca87

File tree

9 files changed

+18
-4
lines changed

9 files changed

+18
-4
lines changed

app/models/authentication.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def self.new(*args, &block)
4545
include OwnershipMixin
4646
include TenancyMixin
4747

48+
validates :name, :length => {:maximum => 128}
49+
4850
belongs_to :tenant
4951

5052
# TODO: DELETE ME!!!!

app/models/cloud_tenant.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class CloudTenant < ApplicationRecord
3030
has_many :flavors, :through => :cloud_tenant_flavors
3131
has_many :cloud_volume_types, :through => :ext_management_system
3232

33+
validates :name, :length => {:maximum => 128}
34+
3335
alias_method :direct_cloud_networks, :cloud_networks
3436

3537
acts_as_miq_taggable

app/models/cloud_volume_snapshot.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class CloudVolumeSnapshot < ApplicationRecord
1515

1616
virtual_total :total_based_volumes, :based_volumes
1717

18+
validates :description, :length => {:maximum => 50}
19+
1820
def self.class_by_ems(ext_management_system)
1921
ext_management_system&.class_by_ems(:CloudVolumeSnapshot)
2022
end

app/models/generic_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GenericObject < ApplicationRecord
1010
has_one :picture, :through => :generic_object_definition
1111
has_many :custom_button_events, :foreign_key => :target_id, :dependent => :destroy
1212

13-
validates :name, :presence => true
13+
validates :name, :presence => true, :length => {:maximum => 255}
1414

1515
delegate :property_attribute_defined?,
1616
:property_defined?,

app/models/miq_alert.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class MiqAlert < ApplicationRecord
99
serialize :options
1010

1111
validates :description, :presence => true, :uniqueness_when_changed => true, :length => {:maximum => 255}
12+
validates :name, :length => {:maximum => 512}
1213
validate :validate_automate_expressions
1314
validate :validate_single_expression
1415
validates :severity, :inclusion => {:in => SEVERITIES}

app/models/pxe_image.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class PxeImage < ApplicationRecord
55

66
has_many :customization_templates, :through => :pxe_image_type
77

8+
validates :name, :length => {:maximum => 255}
9+
810
acts_as_miq_taggable
911

1012
before_validation do

app/models/time_profile.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class TimeProfile < ApplicationRecord
77
default_value_for :days, ALL_DAYS
88
default_value_for :hours, ALL_HOURS
99

10+
validates :description, :length => {:maximum => 128}
11+
1012
has_many :miq_reports
1113
has_many :metric_rollups
1214

app/models/vm_or_template.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ class VmOrTemplate < ApplicationRecord
6161
POWER_OPS = %w[start stop suspend reset shutdown_guest standby_guest reboot_guest]
6262
REMOTE_REGION_TASKS = POWER_OPS + %w[retire_now]
6363

64-
validates_presence_of :name, :location
64+
# NOTE: different react forms set a maxLength of 50 or 128
65+
validates :name, :presence => true, :length => {:maximum => 128}
66+
validates :description, :length => {:maximum => 100}
67+
validates :location, :presence => true
6568
validates :vendor, :inclusion => {:in => VENDOR_TYPES.keys}
6669

6770
has_one :operating_system, :dependent => :destroy

app/models/zone.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Zone < ApplicationRecord
2-
validates_presence_of :name, :description
3-
validates :name, :unique_within_region => true
2+
validates :name, :unique_within_region => true, :presence => true, :length => {:maximum => 128}
3+
validates :description, :presence => true, :length => {:maximum => 128}
44

55
serialize :settings, :type => Hash
66

0 commit comments

Comments
 (0)