Skip to content

Commit

Permalink
Add validating block method
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyshields committed Apr 21, 2024
1 parent 28f4f8b commit 27d699d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/mongoid/validatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def exit_validate
Threaded.exit_validate(self)
end

# Perform a validation within the associated block.
def validating
begin_validate
yield
ensure
exit_validate
end

# Given the provided options, are we performing validations?
#
# @example Are we performing validations?
Expand Down

0 comments on commit 27d699d

Please sign in to comment.