2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2023-03-10 14:49:19 +00:00
|
|
|
class Validations::ObjectManager::AttributeValidator::Backend
|
2021-07-06 07:52:22 +00:00
|
|
|
def self.validate(...)
|
|
|
|
|
new(...).validate
|
2019-03-13 23:51:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
attr_reader :record, :attribute, :value, :previous_value
|
|
|
|
|
|
|
|
|
|
def initialize(record:, attribute:)
|
|
|
|
|
@record = record
|
|
|
|
|
@attribute = attribute
|
|
|
|
|
@value = record[attribute.name]
|
|
|
|
|
@previous_value = record.attribute_in_database(attribute.name)
|
|
|
|
|
end
|
|
|
|
|
|
2024-01-03 07:47:59 +00:00
|
|
|
def invalid_because_attribute(message, **)
|
|
|
|
|
record.errors.add attribute.name.to_sym, message, **
|
2019-03-13 23:51:22 +00:00
|
|
|
end
|
|
|
|
|
end
|