Sha256: fa9ecf9e4e3512f16da7fabccca28a5a5e0b598bbbf1c6642e2f36fce62a246b

Contents?: true

Size: 324 Bytes

Versions: 9

Compression:

Stored size: 324 Bytes

Contents

require 'active_model'

# validates :key, 'quby/type': {is_a: Symbol}
module Quby::Compiler
  class TypeValidator < ActiveModel::EachValidator
    def validate_each(record, attribute, value)
      return if value.is_a? options[:is_a]

      record.errors.add(attribute, "Is not of type #{options[:is_a]}")
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
quby-compiler-0.5.9 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.8 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.7 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.6 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.5 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.4 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.3 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.2 lib/quby/compiler/type_validator.rb
quby-compiler-0.5.1 lib/quby/compiler/type_validator.rb