Sha256: 04348880beb4164f5c05cb9d4c3eba3795d6a79ec9cf180e4e4431a7456fa436

Contents?: true

Size: 945 Bytes

Versions: 48

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

# https://guides.rubyonrails.org/active_record_validations.html#validates-with
module Dsu
  module Validators
    class VersionValidator < ActiveModel::Validator
      def validate(record)
        version = record.version

        if version.nil?
          record.errors.add(:version, 'is nil')
          return
        end

        unless version.is_a?(Integer)
          record.errors.add(:version, 'is the wrong object type. ' \
                                      "\"Integer\" was expected, but \"#{version.class}\" was received.")
          nil
        end

        # TODO: This validation should check the configuration version
        # against the current migration version and they should match.
        # unless version == record.class::VERSION
        #   record.errors.add(:version, "\"#{version}\" is not the correct version: \"#{record.class::VERSION}\"")
        # end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/validators/version_validator.rb
dsu-3.0.4 lib/dsu/validators/version_validator.rb
dsu-3.0.3 lib/dsu/validators/version_validator.rb
dsu-3.0.1 lib/dsu/validators/version_validator.rb
dsu-3.0.0 lib/dsu/validators/version_validator.rb
dsu-3.0.0.beta.3 lib/dsu/validators/version_validator.rb
dsu-3.0.0.beta.2 lib/dsu/validators/version_validator.rb
dsu-3.0.0.beta.1 lib/dsu/validators/version_validator.rb
dsu-3.0.0.beta.0 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.12 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.11 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.10 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.9 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.8 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.7 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.6 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.5 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.4 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.3 lib/dsu/validators/version_validator.rb
dsu-3.0.0.alpha.2 lib/dsu/validators/version_validator.rb