Sha256: 7dff0ba902b1c5be942c00a937c8883bed6bf23ff8481936c6fa73cb97ba0edb
Contents?: true
Size: 518 Bytes
Versions: 1
Compression:
Stored size: 518 Bytes
Contents
module BusinessFlow # Validate that a given value is not nil, but allow blank/empty values. class NotNilValidator < ActiveModel::Validator # :reek:NilCheck :reek:UtilityFunction # Dear reek -- I didn't decided the ActiveModel Validator API, I just # have to live with it. def validate(record) record.class.needs.each do |attribute| value = record.read_attribute_for_validation(attribute) record.errors[attribute] << 'must not be nil' if value.nil? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
business_flow-0.7.0 | lib/business_flow/not_nil_validator.rb |