Sha256: 7384a4e96ffc61a8df5ba2238eccd16e80de370cc7e9fb11ac8b8b66e4a431e9

Contents?: true

Size: 499 Bytes

Versions: 3

Compression:

Stored size: 499 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 %s is not valid") % attrs['capacity'])
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_kubevirt-0.3.0 app/validators/volume_validator.rb
foreman_kubevirt-0.2.1 app/validators/volume_validator.rb
foreman_kubevirt-0.2.0 app/validators/volume_validator.rb