Class: Knight::Rule::Presence

Inherits:
Knight::Rule show all
Defined in:
lib/knight/rule/presence.rb

Overview

A rule for checking the presence of a value

Constant Summary collapse

DEFAULT_MESSAGE =
"%{attribute} can't be blank".freeze

Instance Attribute Summary

Attributes inherited from Knight::Rule

#attribute_name, #message, #options

Instance Method Summary collapse

Methods inherited from Knight::Rule

#error, #initialize, #to_hash

Constructor Details

This class inherits a constructor from Knight::Rule

Instance Method Details

#matches?(value) ⇒ true, false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Check the presence of a value

Parameters:

  • value (Object)

Returns:

  • (true)

    if not blank

  • (false)

    otherwise



18
19
20
# File 'lib/knight/rule/presence.rb', line 18

def matches?(value)
  !blank?(value)
end