Sha256: 2f4720475ff78f529de99028eb5a5c0a225bc06c25764220315ac6933669c70f

Contents?: true

Size: 497 Bytes

Versions: 2

Compression:

Stored size: 497 Bytes

Contents

class VolumeValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    if value[:volumes_attributes].present?
      value[:volumes_attributes].each do |_, attrs|
        if attrs.key?("capacity") && attrs.key?("storage_class")
          if attrs["capacity"].to_s.empty? || /\A\d+G?\Z/.match(attrs["capacity"].to_s).nil?
            record.errors.add(attribute, _("Volume size #{attrs['capacity']} is not valid"))
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_kubevirt-0.1.9 app/validators/volume_validator.rb
foreman_kubevirt-0.1.8 app/validators/volume_validator.rb