class PureValidator::Validators::NotNilValidator
Public Class Methods
validate(value, presence)
click to toggle source
Validates that given object not nil @param value [Object] object to validate @param presence [Boolean] validation options, check presence or not @return [Array] empty array if object is valid, array of error messages otherwise
# File lib/pure_validator/validators/not_nil_validator.rb, line 7 def self.validate(value, presence) errors = [] if presence if value.nil? errors << PureValidator::I18n.t('errors.can_not_be_nil') end else if value errors << PureValidator::I18n.t('errors.should_be_nil') end end errors end
validate_options(presence_flag)
click to toggle source
# File lib/pure_validator/validators/not_nil_validator.rb, line 21 def self.validate_options(presence_flag) PureValidator::ArgsValidator.is_boolean!(presence_flag, :validation_rule) end