apoc.util.validate

Procedure APOC Core

apoc.util.validate(predicate, message, params) | if the predicate yields to true raise an exception

Signature

apoc.util.validate(predicate :: BOOLEAN?, message :: STRING?, params :: LIST? OF ANY?) :: VOID

Input parameters

Name Type Default

predicate

BOOLEAN?

null

message

STRING?

null

params

LIST? OF ANY?

null

Usage Examples

The following throws an exception because the predicate is true:

WITH true AS predicate
CALL apoc.util.validate(predicate,'message %d',[42])
RETURN count(*);
Table 1. Results

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

The following does nothing because the predicate is false:

WITH false AS predicate
CALL apoc.util.validate(predicate,'message %d',[42])
RETURN count(*);
Table 2. Results
count(*)

1