apoc.util.validatePredicate

Function

apoc.util.validatePredicate(predicate BOOLEAN, message STRING, params LIST<ANY>) - if the given predicate is true an exception is thrown, otherwise it returns true (for use inside WHERE subclauses).

Signature

apoc.util.validatePredicate(predicate :: BOOLEAN, message :: STRING, params :: LIST<ANY>) :: BOOLEAN

Input parameters

Name Type Default

predicate

BOOLEAN

null

message

STRING

null

params

LIST<ANY>

null

Usage Examples

The following throws an exception because the predicate is true:

MATCH (a)
WHERE apoc.util.validatePredicate(true,'message %d',[42])
RETURN a
Table 1. Results

Failed to invoke procedure apoc.util.validatePredicate: Caused by: java.lang.RuntimeException: message 42

The following returns true because the predicate is false:

RETURN apoc.util.validatePredicate(false,'message %d',[42]) AS result
Table 2. Results
result

true