Sha256: d75eafdfd4e072cfe772e0d677019bf5f6ad7827c4307c4edcf41663664707ce
Contents?: true
Size: 353 Bytes
Versions: 2
Compression:
Stored size: 353 Bytes
Contents
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
schema_validations-2.3.0 | lib/schema_validations/validators/not_nil_validator.rb |
schema_validations-2.2.1 | lib/schema_validations/validators/not_nil_validator.rb |