Class: SmartCore::Schema::Checker::Rules::Options::Filled Private

Inherits:
Empty
  • Object
show all
Defined in:
lib/smart_core/schema/checker/rules/options/filled.rb

Overview

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

Since:

  • 0.1.0

Constant Summary collapse

ERROR_CODE =

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

Note:

Constant is used only for other developers.

Returns:

  • (Symbol)

Since:

  • 0.1.0

:non_filled

Instance Method Summary collapse

Methods inherited from Empty

#initialize

Constructor Details

This class inherits a constructor from SmartCore::Schema::Checker::Rules::Options::Empty

Instance Method Details

#validate(verifiable_hash) ⇒ SmartCore::Schema::Checker::Rules::Result::Success, SmartCore::Schema::Checker::Rules::Result::Failure

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.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/smart_core/schema/checker/rules/options/filled.rb', line 20

def validate(verifiable_hash)
  schema_value = verifiable_hash[schema_key]

  if non_filled?(schema_value)
    SmartCore::Schema::Checker::Rules::Result::Failure.new(
      key: schema_key,
      value: schema_value,
      error: ERROR_CODE,
      message: 'Requires to be filled'
    )
  else
    SmartCore::Schema::Checker::Rules::Result::Success.new(
      key: schema_key,
      value: schema_value
    )
  end
end