Method: Protector::Adapters::Sequel::Model#validate

Defined in:
lib/protector/adapters/sequel/model.rb

#validateObject

Basic security validations



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/protector/adapters/sequel/model.rb', line 68

def validate
  super
  return unless protector_subject?

  # rubocop:disable IndentationWidth, EndAlignment
  field = if new?
    protector_meta.first_uncreatable_field protector_changed(keys)
  else
    protector_meta.first_unupdatable_field protector_changed(changed_columns)
  end
  # rubocop:enable IndentationWidth, EndAlignment

  errors.add :base, I18n.t('protector.invalid', field: field) if field
end