Class: Burner::Modeling::Validations::Blank

Inherits:
Base
  • Object
show all
Defined in:
lib/burner/modeling/validations/blank.rb

Overview

Check if a value is blank, if it is not blank then it is not valid.

Direct Known Subclasses

Present

Constant Summary collapse

BLANK_RE =
/\A[[:space:]]*\z/.freeze

Instance Attribute Summary

Attributes inherited from Base

#key

Instance Method Summary collapse

Methods inherited from Base

#initialize, #message

Constructor Details

This class inherits a constructor from Burner::Modeling::Validations::Base

Instance Method Details

#valid?(object, resolver) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/burner/modeling/validations/blank.rb', line 21

def valid?(object, resolver)
  value = resolver.get(object, key).to_s

  value.empty? || BLANK_RE.match?(value)
end