Sha256: 75cfb8ff427464d58ab823dbe013820ce28a427c7e6f17bf9b4f57dee8761b0c

Contents?: true

Size: 820 Bytes

Versions: 32

Compression:

Stored size: 820 Bytes

Contents

module Neo4j
  module PropertyValidator
    require 'set'
    class InvalidPropertyException < Exception

    end

    # the valid values on a property, and arrays of those.
    VALID_PROPERTY_VALUE_CLASSES = Set.new([Array, NilClass, String, Float, TrueClass, FalseClass, Fixnum])

    # @param [Object] value the value we want to check if it's a valid neo4j property value
    # @return [True, False] A false means it can't be persisted.
    def valid_property?(value)
      VALID_PROPERTY_VALUE_CLASSES.include?(value.class)
    end

    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
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
neo4j-core-3.1.1 lib/neo4j/property_validator.rb
neo4j-core-3.1.0 lib/neo4j/property_validator.rb
neo4j-core-3.0.8 lib/neo4j/property_validator.rb
neo4j-core-3.0.7 lib/neo4j/property_validator.rb
neo4j-core-3.0.6 lib/neo4j/property_validator.rb
neo4j-core-3.0.5 lib/neo4j/property_validator.rb
neo4j-core-3.0.4 lib/neo4j/property_validator.rb
neo4j-core-3.0.3 lib/neo4j/property_validator.rb
neo4j-core-3.0.2 lib/neo4j/property_validator.rb
neo4j-core-3.0.1 lib/neo4j/property_validator.rb
neo4j-core-3.0.0 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.rc.5 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.rc.4 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.rc.1 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.19 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.18 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.17 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.16 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.15 lib/neo4j/property_validator.rb
neo4j-core-3.0.0.alpha.14 lib/neo4j/property_validator.rb