mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-01-06 08:27:47 -05:00
8 lines
250 B
Ruby
8 lines
250 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ApprovedValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, _value)
|
|
record.errors.add(attribute, options[:message] || 'must be approved') unless record.crop.try(:approved?)
|
|
end
|
|
end
|