Sha256: 40e236021736a433e36eaad3f8e69381e267282dbc7886eb8b2cfe185eae4b00

Contents?: true

Size: 815 Bytes

Versions: 21

Compression:

Stored size: 815 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, Integer])

    # @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.any? { |c| value.is_a?(c) }
    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

21 entries across 21 versions & 1 rubygems

Version Path
neo4j-core-8.1.4 lib/neo4j/property_validator.rb
neo4j-core-8.1.3 lib/neo4j/property_validator.rb
neo4j-core-8.1.2 lib/neo4j/property_validator.rb
neo4j-core-8.1.1 lib/neo4j/property_validator.rb
neo4j-core-8.1.0 lib/neo4j/property_validator.rb
neo4j-core-8.0.4 lib/neo4j/property_validator.rb
neo4j-core-8.0.3 lib/neo4j/property_validator.rb
neo4j-core-8.0.2 lib/neo4j/property_validator.rb
neo4j-core-8.0.1 lib/neo4j/property_validator.rb
neo4j-core-7.2.4 lib/neo4j/property_validator.rb
neo4j-core-8.0.0 lib/neo4j/property_validator.rb
neo4j-core-7.2.3 lib/neo4j/property_validator.rb
neo4j-core-7.2.2 lib/neo4j/property_validator.rb
neo4j-core-7.2.1 lib/neo4j/property_validator.rb
neo4j-core-7.2.0 lib/neo4j/property_validator.rb
neo4j-core-7.1.2 lib/neo4j/property_validator.rb
neo4j-core-7.0.9 lib/neo4j/property_validator.rb
neo4j-core-7.1.1 lib/neo4j/property_validator.rb
neo4j-core-7.1.0 lib/neo4j/property_validator.rb
neo4j-core-7.0.8 lib/neo4j/property_validator.rb