lib/kwalify/meta-validator.rb in kwalify-0.3.0 vs lib/kwalify/meta-validator.rb in kwalify-0.4.0

- old
+ new

@@ -1,8 +1,8 @@ ### -### $Rev: 21 $ -### $Release: 0.3.0 $ +### $Rev: 35 $ +### $Release: 0.4.0 $ ### copyright(c) 2005 kuwata-lab all rights reserved. ### require 'kwalify/errors' require 'kwalify/rule' @@ -96,11 +96,11 @@ #required: yes "mapping": name: MAPPING type: map mapping: - '*': + =: type: map mapping: *main-rule name: MAIN #required: yes END @@ -108,11 +108,11 @@ ## ## ex. ## meta_validator = Kwalify.meta_validator() ## schema = File.load_file('schema.yaml') - ## errors << meta_validator.validate(schema) + ## errors = meta_validator.validate(schema) ## if !errors.empty? ## errors.each do |error| ## puts "[#{error.path}] #{error.message}" ## end ## end @@ -267,12 +267,12 @@ end # if hash.key?('mapping') val = hash['mapping'] if val != nil && !val.is_a?(Hash) - errors << validate_error(:mapping_notmap, rule, "#{path}/mapping", val) - elsif val == nil || val.empty? - errors << validate_error(:mapping_noelem, rule, "#{path}/mapping", val) + errors << validate_error(:mapping_notmap, rule, "#{path}/mapping", val) + elsif val == nil || (val.empty? && !val.default) + errors << validate_error(:mapping_noelem, rule, "#{path}/mapping", val) end end # if type == 'seq' errors << validate_error(:seq_nosequence, rule, path, nil) unless hash.key?('sequence')