Class GEValidator
java.lang.Object
net.mcreator.element.util.GEValidator
This class provides validation functionality for generatable elements and their fields.
It leverages reflection to inspect and validate fields recursively and attempts to
correct invalid values when possible based on attached annotations.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidvalidateAndTryToCorrect(GeneratableElement element, Consumer<String> validationLog) Validates the given generatable element and recursively checks all nested custom objects, collections, maps, and arrays using reflection.
-
Constructor Details
-
GEValidator
public GEValidator()
-
-
Method Details
-
validateAndTryToCorrect
public static void validateAndTryToCorrect(GeneratableElement element, @Nullable Consumer<String> validationLog) throws GEValidator.ValidationException Validates the given generatable element and recursively checks all nested custom objects, collections, maps, and arrays using reflection. Supported validation annotations: -Nonnull: field value must not benull(exception) -Numeric: numeric value must be within allowed bounds (tries to correct) -LimitedOptions: value must match one of the allowed options (tries to correct)- Parameters:
element- the element to validatevalidationLog- optional consumer to log validation messages; ifnull, no logging is performed- Throws:
GEValidator.ValidationException- if validation fails in non-recoverable way or reflective access fails
-