Class: OpenvasCli::ImmutableChildrenValidator

Inherits:
ActiveModel::Validator
  • Object
show all
Defined in:
lib/openvas-cli/immutable_children_validator.rb

Instance Method Summary collapse

Instance Method Details

#validate(record) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/openvas-cli/immutable_children_validator.rb', line 5

def validate(record)
  if record.id
    record.errors[:base] << "Configuration cannot change after creation." \
      if record.config_id_changed?
      
    record.errors[:base] << "Target cannot change after creation." \
      if record.target_id_changed? || record.target.changed?
  end
end