Sha256: fe45c08e45b646f354112b3fc92fa7cacac741de93f1b40285f2b2a280a750df

Contents?: true

Size: 933 Bytes

Versions: 3

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

require_relative 'field_validator'

module Dragnet
  module Validators
    module Fields
      # Validates the files field on a Manual Test Record
      class FilesValidator < Dragnet::Validators::Fields::FieldValidator
        # Validates the MTR's +files+ array.
        # @param [String] key The name of the key
        # @param [Object] value The value of the key
        # @return [Array<String>, nil] If +files+ is an Array or a String then
        #   an array is returned, if +files+ is +nil+ then +nil+ is returned.
        # @raise [Dragnet::Errors::ValidationError] If the +files+ key is not a
        #   +String+ or an +Array+ of +String+s.
        def validate(key, value)
          return unless value

          validate_type(key, value, String, Array)
          value = *value
          validate_array_types(key, value, String)

          value
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dragnet-5.3.1 lib/dragnet/validators/fields/files_validator.rb
dragnet-5.3.0 lib/dragnet/validators/fields/files_validator.rb
dragnet-5.2.1 lib/dragnet/validators/fields/files_validator.rb