class SmartCore::Schema::Checker::Rules::Options::Filled

@api private @since 0.1.0

Constants

ERROR_CODE

@note Constant is used only for other developers. @return [Symbol]

@api private @since 0.1.0

Public Instance Methods

validate(verifiable_hash) click to toggle source

@param verifiable_hash [SmartCore::Schema::Checker::VerifiableHash] @return [SmartCore::Schema::Checker::Rules::Result::Success] @return [SmartCore::Schema::Checker::Rules::Result::Failure]

@api private @since 0.1.0

# 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

Private Instance Methods

non_filled?(value) click to toggle source

@param value [Any] @return [Boolean]

@api private @since 0.1.0

# File lib/smart_core/schema/checker/rules/options/filled.rb, line 45
def non_filled?(value)
  value == nil
end