class BoxGrinder::ApplianceValidator

Public Class Methods

new(schema) click to toggle source
# File lib/boxgrinder-core/appliance-validator.rb, line 24
def initialize(schema)
  super(schema) # Super constructor
end

Public Instance Methods

validate_hook(value, rule, path, errors) click to toggle source
# File lib/boxgrinder-core/appliance-validator.rb, line 28
def validate_hook(value, rule, path, errors)
  case rule.name
    when 'Repository' # enforce baseurl xor mirrorlist
      errors << Kwalify::ValidationError.new("Please specify either a baseurl or a mirrorlist.", path) unless value['baseurl'].nil? ^ value['mirrorlist'].nil?
    when 'Hardware' # enforce multiple of 64
      errors << Kwalify::ValidationError.new("Specified memory amount: #{value['memory']} is invalid. The value must be a multiple of 64.", path) unless value['memory'].nil? or value['memory']%64==0
  end
end