lib/github_bot/validator/base.rb
# Public: Validates for the provided file at a given hash point that the
# allowed fields are met
#
# @param file [Sawyer::Resource] The file for reference that is being evaluated
# @param ident [String/Symbol] The text identifier for the hash being evaluated
# @param hash [Hash] The hash to review keys
# @param allowed_fields [Array] An array of allowed fields
Validates for the provided file at a given hash point that the
allowed fields are met
Validates for the provided file at a given hash point that the allowed fields are met
def validate_allowed_fields(file:, ident:, hash:, allowed_fields:, **_opts)
        unless hash
          feedback(
            path: file.filename,
            annotation_level: 'failure',
            message: "#{ident}: Element is empty or nil"
          )
          return
        end
        hash.keys&.each do |key|
          unless allowed_fields.include?(key)
            feedback(
              path: file.filename,
              annotation_level: 'failure',
              message: "#{ident}: Key '#{key}' not in the allowed fields [#{allowed_fields.join(', ')}]"
            )
          end
        end
      end
def validate_allowed_fields ( file : , ident : , hash : , allowed_fields : , ** _opts ) unless hash feedback ( path : file . filename , annotation_level : 'failure' , message : "#{ident}: Element is empty or nil" ) return end hash . keys &. each do | key | unless allowed_fields . include? ( key ) feedback ( path : file . filename , annotation_level : 'failure' , message : "#{ident}: Key '#{key}' not in the allowed fields [#{allowed_fields.join(', ')}]" ) end end end
Public: Validates for the provided file at a given hash point that the
allowed fields are met
Public : Validates for the provided file at a given hash point that the allowed fields are met
file
The file for reference that is being evaluated
The file for reference that is being evaluated
ident
The text identifier for the hash being evaluated
The text identifier for the hash being evaluated
hash
The hash to review keys
The hash to review keys
allowed_fields
An array of allowed fields
An array of allowed fields
_opts
<not_specific>