Class: DiasporaFederation::Validators::OptionalAwareValidator

Inherits:
Validation::Validator
  • Object
show all
Defined in:
lib/diaspora_federation/validators/optional_aware_validator.rb

Overview

Abstract validator which only validates optional fields when they are not nil.

Instance Method Summary collapse

Instance Method Details

#rulesObject



7
8
9
10
11
12
13
# File 'lib/diaspora_federation/validators/optional_aware_validator.rb', line 7

def rules
  super.reject do |field, rules|
    @obj.public_send(field).nil? &&
      !rules.map(&:class).include?(Validation::Rule::NotNil) &&
      optional_props.include?(field)
  end
end