Sha256: 74b8dbf93ca75af215b58b79842fdc0a1a9be8df2e2c2a16f2e544d0dd0dc1e2

Contents?: true

Size: 384 Bytes

Versions: 1

Compression:

Stored size: 384 Bytes

Contents

# frozen_string_literal: true

module SchemaValidations
  module Validators
    # Validates that the field is not nil?
    # (Unlike the standard PresenceValidator which uses #blank?)
    class NotNilValidator < ActiveModel::EachValidator
      def validate_each(record, attr_name, value)
        record.errors.add(attr_name, :blank, options) if value.nil?
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
schema_validations-2.4.0 lib/schema_validations/validators/not_nil_validator.rb