Skip to content

Rails/Validation does not cover validates_comparison_of #1295

Closed
@ChaelCodes

Description

@ChaelCodes

Currently Rails/Validation does not cover the validation helper validates_comparison_of.

Expected behavior

For a model with the following validations:

  validates_presence_of :start_at, :end_at
  validates_comparison_of :end_at, greater_than: :start_at

Both validation helpers raise an error if Rails/Validation is Enabled.

Actual behavior

Only validates_presence_of triggers an error.

Steps to reproduce the problem

Add the old-style attribute validation macro for comparison to a model.

  validates_comparison_of :end_at, greater_than: :start_at

Run rubocop.

RuboCop version

$ bundle exec rubocop -V
1.57.1 (using Parser 3.2.2.4, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-linux-musl]
  - rubocop-capybara 2.19.0
  - rubocop-factory_bot 2.24.0
  - rubocop-rails 2.21.2
  - rubocop-rspec 2.24.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions