Class GEValidator

java.lang.Object
net.mcreator.element.util.GEValidator

public class GEValidator extends Object
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.
  • Constructor Details

    • GEValidator

      public GEValidator()
  • Method Details

    • validateAndTryToCorrect

      public static void validateAndTryToCorrect(GeneratableElement element) 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 be null (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 validate
      Throws:
      GEValidator.ValidationException - if validation fails or reflective access fails