def validate_presence_of_required_fields form, fields
      absent_fields = []
      fields.each_pair do |key, opts|
        next  unless opts[:required]
        if !form.has_key?(key) || form[key].nil?
          absent_fields << key
        end
      end
      unless absent_fields.empty?
        raise RegApi2::ContractError.new(
          "Required fields missed: #{absent_fields.join(', ')}",
          absent_fields
        )
      end
      nil
    end
def validate_presence_of_required_fields form, fields
      absent_fields = []
      fields.each_pair do |key, opts|
        next  unless opts[:required]
        if !form.has_key?(key) || form[key].nil?
          absent_fields << key
        end
      end
      unless absent_fields.empty?
        raise RegApi2::ContractError.new(
          "Required fields missed: #{absent_fields.join(', ')}",
          absent_fields
        )
      end
      nil
    end
Validates specified `form` for presence of all required fields.
 @param [Hash] form Form to validate.
 @param [Hash] fields Fields to test.
 return void
 @raise ContractError