Class: Mixture::Validate::Presence

Inherits:
Base
  • Object
show all
Defined in:
lib/mixture/validate/presence.rb

Overview

Checks that a value is present.

Instance Method Summary collapse

Methods inherited from Base

#initialize, register_as

Constructor Details

This class inherits a constructor from Mixture::Validate::Base

Instance Method Details

#validate(record, attribute, value) ⇒ void

This method returns an undefined value.

Performs the validation.

Parameters:

  • record (Mixture::Model)

    The model that has the attribute. At least, it should respond to #errors.

  • attribute (Attribute)

    The attribute to validate.

  • value (Object)

    The value of the attribute.

Raises:


13
14
15
16
# File 'lib/mixture/validate/presence.rb', line 13

def validate(record, attribute, value)
  super
  error("Value is empty") if empty?
end