Class: Xeroizer::Record::Validator::PresenceOfValidator

Inherits:
Xeroizer::Record::Validator show all
Defined in:
lib/xeroizer/record/validators/presence_of_validator.rb

Instance Attribute Summary

Attributes inherited from Xeroizer::Record::Validator

#attribute, #options

Instance Method Summary (collapse)

Methods inherited from Xeroizer::Record::Validator

#condition?, #initialize, #run_validator?, #validate

Constructor Details

This class inherits a constructor from Xeroizer::Record::Validator

Instance Method Details

- (Boolean) valid?(record)

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/xeroizer/record/validators/presence_of_validator.rb', line 8

def valid?(record)
  if record[attribute].nil? || record[attribute].to_s == ''
    record.errors << [attribute, options[:message] || "can't be blank"]
  end
end