apoc.util.validate

Details

Syntax

apoc.util.validate(predicate, message, params)

Description

If the given predicate is true an exception is thrown.

Input arguments

Name

Type

Description

predicate

BOOLEAN

The predicate to check against.

message

STRING

The error message to throw if the given predicate evaluates to true.

params

LIST<ANY>

The parameters for the given error message.

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(*);
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(*);
Results
count(*)

1