Sha256: beb9c89e3abeb18f385b3b35a40e9ab4686a78714008c79df3ab408fa5a7aaa4

Contents?: true

Size: 552 Bytes

Versions: 2

Compression:

Stored size: 552 Bytes

Contents

# encoding: utf-8
# frozen_string_literal: true

module Mixture
  module Validate
    # Checks to make sure that the value is in the given set.  This
    # uses the `#includes?` method on the `@options`.
    class Inclusion < Base
      register_as :inclusion
      # Performs the validation.
      #
      # @param (see Base#validate)
      # @return (see Base#validate)
      def validate(record, attribute, value)
        super
        error("Value isn't in the given set") unless
          @options[:in].include?(value)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixture-0.7.1 lib/mixture/validate/inclusion.rb
mixture-0.7.0 lib/mixture/validate/inclusion.rb