Sha256: e187e31b7942385ed4cfabef54d42a461b4391b9c8d5639dfa2fd2c766dbd45b

Contents?: true

Size: 255 Bytes

Versions: 4

Compression:

Stored size: 255 Bytes

Contents

class AllowedTypeValidator < ActiveModel::EachValidator
  def validate_each(record, name, value)
    if options[:in].find { |klass| value.is_a?(klass) }.nil?
      record.errors[name] << "does not have the expected type #{options[:in]}"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
avromatic-1.0.0 lib/avromatic/model/allowed_type_validator.rb
avromatic-0.33.0 lib/avromatic/model/allowed_type_validator.rb
avromatic-0.32.0 lib/avromatic/model/allowed_type_validator.rb
avromatic-0.32.0.rc0 lib/avromatic/model/allowed_type_validator.rb