class AWS::Record::PresenceValidator
@api private
Constants
- ACCEPTED_OPTIONS
Public Instance Methods
message()
click to toggle source
# File lib/aws/record/validators/presence.rb, line 37 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 22 def validate_attribute record, attribute_name, value blank = case when value.nil? then true when value.is_a?(String) then value !~ /\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