Sha256: 3ba905335f226916f6997139e309c1595d12f4651e7ed863c5bb5779234eddb1

Contents?: true

Size: 424 Bytes

Versions: 9

Compression:

Stored size: 424 Bytes

Contents

module BusinessFlow
  # Validate that a given value is not nil, but allow blank/empty values.
  class NotNilValidator < ActiveModel::EachValidator
    # :reek:NilCheck :reek:UtilityFunction
    # Dear reek -- I didn't decided the ActiveModel Validator API, I just
    # have to live with it.
    def validate_each(record, attribute, value)
      record.errors[attribute] << 'must not be nil' if value.nil?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
business_flow-0.4.3 lib/business_flow/not_nil_validator.rb
business_flow-0.4.2 lib/business_flow/not_nil_validator.rb
business_flow-0.4.1 lib/business_flow/not_nil_validator.rb
business_flow-0.4.0 lib/business_flow/not_nil_validator.rb
business_flow-0.3.0 lib/business_flow/not_nil_validator.rb
business_flow-0.2.0 lib/business_flow/not_nil_validator.rb
business_flow-0.1.2 lib/business_flow/not_nil_validator.rb
business_flow-0.1.1 lib/business_flow/not_nil_validator.rb
business_flow-0.1.0 lib/business_flow/not_nil_validator.rb