checks_condition_validation.rb 501 B

1234567891011121314
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module ChecksConditionValidation
  3. extend ActiveSupport::Concern
  4. included do
  5. before_create :validate_condition
  6. before_update :validate_condition
  7. end
  8. def validate_condition
  9. raise Exceptions::UnprocessableEntity, __('Invalid object selector conditions') if !Selector::Sql.new(selector: condition, options: { current_user: User.find(1) }, target_class: try(:object)&.constantize || Ticket).valid?
  10. end
  11. end