class AWS::Record::PresenceValidator

@private

Constants

ACCEPTED_OPTIONS

Public Instance Methods

message() click to toggle source
# File lib/aws/record/validators/presence.rb, line 39
def message
  options[:message] || 'may not be blank'
end
validate_attribute(record, attribute_name, value) click to toggle source
# File lib/aws/record/validators/presence.rb, line 24
def validate_attribute record, attribute_name, value

  blank = case
  when value.nil?                 then true
  when value.is_a?(String)        then value !~ %r\S/
  when value == false             then false # defeat false.blank? == true
  when value.respond_to?(:empty?) then value.empty?
  when value.respond_to?(:blank?) then value.blank?
  else false
  end

  record.errors.add(attribute_name, message) if blank

end