cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Setting constraints on property values?

I have been reading cypher documentation but am still very unsure on how to achieve the following:

  1. Set a constraint on n:LABEL nodes in such way that n.property1 must be a positive integer

  2. Set a constraint on n:LABEL nodes in such wayt that n.property2 must contain one of the values specified in an "enum" (or whatever would be the neo4j equivalent)

The idea here is that I would like to enforce a specific type of schema through constraints. Are either of these in any way possible with just plain cypher?

1 ACCEPTED SOLUTION

Hello,

Neither of these constraint types are currently supported, though we do have an interest in expanding our constraint types in the future.

Currently on node properties we support uniqueness, existence, and node key constraints.

You could implement a before-commit trigger (via APOC or with your own transaction listener) to check for such conditions and fail the transaction if it doesn't adhere to what you're expecting.

View solution in original post

3 REPLIES 3

Hello,

Neither of these constraint types are currently supported, though we do have an interest in expanding our constraint types in the future.

Currently on node properties we support uniqueness, existence, and node key constraints.

You could implement a before-commit trigger (via APOC or with your own transaction listener) to check for such conditions and fail the transaction if it doesn't adhere to what you're expecting.

Thank you! I had not considered APOC functions as a way to trigger transaction fail in case of invalid values - I will start digging through APOC documentation next.

Neosematix (n10s) through SHACL, can also create constrains on property types. It is not a simple as CREATE CONSTRAINT ...., but it works.