Sha256: 5e486af5b0415642de4f7f87174c599de19f1a37cfac73c235ce2b0129b1f8fc
Contents?: true
Size: 583 Bytes
Versions: 6
Compression:
Stored size: 583 Bytes
Contents
module Schemacop class FieldNode < NodeSupportingType attr_reader :name def initialize(name, required, options = {}, &block) if options.any? fail Exceptions::InvalidSchemaError, 'Node does not support options.' end super({}, &block) @name = name @required = required end def validate(data, collector) unless data.key?(name) collector.error "Missing key #{name.inspect}." if @required return end collector.path "/#{name}" do super(data[name], collector) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems