| Class | BoxGrinder::ApplianceValidator |
| In: |
lib/boxgrinder-core/appliance-validator.rb
lib/boxgrinder-core/appliance-validator.rb |
| Parent: | Kwalify::Validator |
# File lib/boxgrinder-core/appliance-validator.rb, line 24
24: def initialize(schema)
25: super(schema) # Super constructor
26: end
# File lib/boxgrinder-core/appliance-validator.rb, line 24
24: def initialize(schema)
25: super(schema) # Super constructor
26: end
# File lib/boxgrinder-core/appliance-validator.rb, line 28
28: def validate_hook(value, rule, path, errors)
29: case rule.name
30: when 'Repository' # enforce baseurl xor mirrorlist
31: errors << Kwalify::ValidationError.new("Please specify either a baseurl or a mirrorlist.", path) unless value['baseurl'].nil? ^ value['mirrorlist'].nil?
32: when 'Hardware' # enforce multiple of 64
33: 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
34: end
35: end
# File lib/boxgrinder-core/appliance-validator.rb, line 28
28: def validate_hook(value, rule, path, errors)
29: case rule.name
30: when 'Repository' # enforce baseurl xor mirrorlist
31: errors << Kwalify::ValidationError.new("Please specify either a baseurl or a mirrorlist.", path) unless value['baseurl'].nil? ^ value['mirrorlist'].nil?
32: when 'Hardware' # enforce multiple of 64
33: 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
34: end
35: end