You can add validations on new fields in you plugin. Example is here
# load plugin file(s)
Rails.configuration.to_prepare do
TimeEntry.send(:include, TimeLimitTimeEntryPatch)
end
# in patch file
module TimeLimitTimeEntryPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
validates_presence_of :comments
validate :validate_time_limit_allowed_ip
end
end
module InstanceMethods
def validate_time_limit_allowed_ip
# add error if permission is not set and IP is not allowed
if !self.class.have_permissions?(user, project) && !time_limit_allowed_ip
errors.add(:hours, I18n.t(:not_allowed_ip))
end
end
end
end