Module: Neo4j::PropertyValidator

Included in:
Embedded::Property, PropertyContainer
Defined in:
lib/neo4j/property_validator.rb

Defined Under Namespace

Classes: InvalidPropertyException

Constant Summary collapse

VALID_PROPERTY_VALUE_CLASSES =

the valid values on a property, and arrays of those.

Set.new([Array, NilClass, String, Float, TrueClass, FalseClass, Fixnum])

Instance Method Summary collapse

Instance Method Details

#valid_property?(value) ⇒ True, False

Returns A false means it can’t be persisted.

Parameters:

  • value (Object)

    the value we want to check if it’s a valid neo4j property value

Returns:

  • (True, False)

    A false means it can’t be persisted.



13
14
15
# File 'lib/neo4j/property_validator.rb', line 13

def valid_property?(value)
  VALID_PROPERTY_VALUE_CLASSES.include?(value.class)
end

#validate_property(value) ⇒ Object



17
18
19
20
21
# File 'lib/neo4j/property_validator.rb', line 17

def validate_property(value)
  unless valid_property?(value)
    raise Neo4j::PropertyValidator::InvalidPropertyException.new("Not valid Neo4j Property value #{value.class}, valid: #{Neo4j::Node::VALID_PROPERTY_VALUE_CLASSES.to_a.join(', ')}")
  end
end