public class ValidatorUtils extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
ValidatorUtils.Handler |
| Constructor and Description |
|---|
ValidatorUtils() |
| Modifier and Type | Method and Description |
|---|---|
static com.sap.cds.CdsDataProcessor.Validator |
assertNotNull(EventContext context,
Predicate<Object> isNull,
ValidatorUtils.Handler errorHandler)
Returns a validator for mandatory annotated elements or elements with not
null constraints.
|
static void |
handleValidationError(EventContext context,
com.sap.cds.ql.cqn.Path path,
com.sap.cds.reflect.CdsElement element,
CdsErrorStatuses statuses,
Object... args)
Handles the given
CdsErrorStatuses by either generating an error
message or throwing a ErrorStatusException. |
static boolean |
requiresNotNullCheck(com.sap.cds.reflect.CdsElement element)
Returns true, if the provided
CdsElement requires a not null check
based on its type, potential default value or whether its draft element. |
static void |
runNotNullCheck(EventContext context,
Predicate<com.sap.cds.reflect.CdsElement> requiredByModel,
com.sap.cds.CdsDataProcessor.Validator validator)
Runs a not null validation against the provided
EventContext with the
given predicate and validator implementation. |
public static boolean requiresNotNullCheck(com.sap.cds.reflect.CdsElement element)
CdsElement requires a not null check
based on its type, potential default value or whether its draft element.element - the cds elementpublic static void runNotNullCheck(EventContext context, Predicate<com.sap.cds.reflect.CdsElement> requiredByModel, com.sap.cds.CdsDataProcessor.Validator validator)
EventContext with the
given predicate and validator implementation.context - the event contextrequiredByModel - predicate returning whether validation is required
based on model annotationsvalidator - the validator implementation to usepublic static void handleValidationError(EventContext context, com.sap.cds.ql.cqn.Path path, com.sap.cds.reflect.CdsElement element, CdsErrorStatuses statuses, Object... args)
CdsErrorStatuses by either generating an error
message or throwing a ErrorStatusException.context - the event contextpath - the relative path to the target elementelement - the target elementstatuses - the cds error statusargs - message argspublic static com.sap.cds.CdsDataProcessor.Validator assertNotNull(EventContext context, Predicate<Object> isNull, ValidatorUtils.Handler errorHandler)
context - the event contextisNull - predicate checking whether an object is set to null (or
an empty string)errorHandler - error handler that takes the element and
entity name that is validatedCopyright © 2022. All rights reserved.