Sha256: cb8bf973f8a65706372ab94520590161ff062d5877574f0d6c840375487d512b

Contents?: true

Size: 808 Bytes

Versions: 66

Compression:

Stored size: 808 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)
      return if valid_property?(value)

      fail Neo4j::PropertyValidator::InvalidPropertyException, "Not valid Neo4j Property value #{value.class}, valid: #{Neo4j::Node::VALID_PROPERTY_VALUE_CLASSES.to_a.join(', ')}"
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
neo4j-core-6.1.3 lib/neo4j/property_validator.rb
neo4j-core-6.1.2 lib/neo4j/property_validator.rb
neo4j-core-6.1.1 lib/neo4j/property_validator.rb
neo4j-core-6.0.6 lib/neo4j/property_validator.rb
neo4j-core-6.0.5 lib/neo4j/property_validator.rb
neo4j-core-6.1.0 lib/neo4j/property_validator.rb
neo4j-core-5.1.14 lib/neo4j/property_validator.rb
neo4j-core-6.0.4 lib/neo4j/property_validator.rb
neo4j-core-6.0.3 lib/neo4j/property_validator.rb
neo4j-core-6.0.2 lib/neo4j/property_validator.rb
neo4j-core-6.0.1 lib/neo4j/property_validator.rb
neo4j-core-6.0.0 lib/neo4j/property_validator.rb
neo4j-core-5.1.12 lib/neo4j/property_validator.rb
neo4j-core-6.0.0.rc.1 lib/neo4j/property_validator.rb
neo4j-core-6.0.0.alpha.6 lib/neo4j/property_validator.rb
neo4j-core-5.1.11 lib/neo4j/property_validator.rb
neo4j-core-5.1.10 lib/neo4j/property_validator.rb
neo4j-core-6.0.0.alpha.5 lib/neo4j/property_validator.rb
neo4j-core-6.0.0.alpha.2 lib/neo4j/property_validator.rb
neo4j-core-5.1.7 lib/neo4j/property_validator.rb