apoc.util.validatePredicate

Details

Syntax

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

Description

If the given predicate is true an exception is thrown, otherwise it returns true (for use inside WHERE subclauses).

Arguments

Name

Type

Description

predicate

BOOLEAN

The predicate to be evaluated.

message

STRING

The error message thrown if the predicate evaluates to true.

params

LIST<ANY>

Parameters to format the message with.

Returns

BOOLEAN

Usage Examples

The following throws an exception because the predicate is true:

MATCH (a)
WHERE apoc.util.validatePredicate(true,'message %d',[42])
RETURN a
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
Results
result

true