class HashValidator::Base attr_accessor :hash, :validations, :errors def initialize(hash, validations) self.errors = {} self.hash = hash self.validations = validations validate end def valid? errors.empty? end def self.validate(hash, validations) new(hash, validations) end private def validate HashValidator.validator_for(hash).validate(:base, self.hash, self.validations, self.errors) self.errors = errors[:base] end end