Skip to content

fix: preserve strict restriction validation failures - #253

Open
ydah wants to merge 1 commit into
adzap:masterfrom
ydah:fix/strict-restriction-validation
Open

ydah wants to merge 1 commit into
adzap:masterfrom
ydah:fix/strict-restriction-validation

Conversation

@ydah

@ydah ydah commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

With ignore_restriction_errors enabled, a violated restriction with strict: true can be treated as valid:

class Event
  include ActiveModel::Model
  include ActiveModel::Attributes

  attribute :d, :date
  validates_date :d, before: :today, strict: true
end

ValidatesTimeliness.ignore_restriction_errors = true
Event.new(d: Date.current).valid? # Returns true before the fix

add_error raises ActiveModel::StrictValidationFailed, but the restriction evaluation's rescue catches it. With error ignoring disabled, that same rescue replaces the original validation message with “Error occurred validating ...”.

Move add_error outside the evaluation rescue so the original strict validation failure propagates in both configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant