Sha256: e2197e057c8d8761caa3a60c689279ac113e5064265cf4b94651a5673793aa7c

Contents?: true

Size: 323 Bytes

Versions: 8

Compression:

Stored size: 323 Bytes

Contents

require "active_model"

module Vindetta
  class Validator < ActiveModel::Validator
    LENGTH = 17

    def self.run(value)
      Vin.new(value).valid?
    end

    def validate(record)
      record.errors.add(:value, I18n.t("invalid_length")) if record.value.length != LENGTH

      # TODO: Check format
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vindetta-0.15.0 lib/vindetta/validator.rb
vindetta-0.14.0 lib/vindetta/validator.rb
vindetta-0.13.0 lib/vindetta/validator.rb
vindetta-0.12.0 lib/vindetta/validator.rb
vindetta-0.11.0 lib/vindetta/validator.rb
vindetta-0.10.0 lib/vindetta/validator.rb
vindetta-0.9.0 lib/vindetta/validator.rb
vindetta-0.8.0 lib/vindetta/validator.rb