Class DataSourceValidationUtils

java.lang.Object
org.elasticsearch.xpack.esql.datasources.spi.DataSourceValidationUtils

public final class DataSourceValidationUtils extends Object
Helpers for DataSourceValidator implementations. The methods here cover the common validation primitives — rejecting unknown fields, validating enums, validating bounded integers — that every file-based and connector-based validator needs.

These helpers live outside the DataSourceValidator interface so the interface stays a pure contract. Implementations should import static the methods they use.

  • Method Details

    • rejectUnknownFields

      public static void rejectUnknownFields(Map<String,Object> settings, Set<String> knownFields, ValidationException errors)
      Adds an error for any keys in the settings map that are not in the known fields set.
      Parameters:
      settings - the settings map to check
      knownFields - the set of valid field names
      errors - the exception to accumulate errors into
    • validateEnum

      public static <E extends Enum<E>> void validateEnum(Map<String,Object> settings, Map<String,Object> result, String field, E[] values, Function<String,? extends E> parser, ValidationException errors)
      Validates that a setting value matches one of the values in the given enum. If present and valid, the original value is stored as-is (no case normalization). Case normalization for datasource settings is handled by DataSourceConfigDefinition.caseInsensitive() in the configuration layer.
      Parameters:
      settings - the raw settings map
      result - the validated result map to add to
      field - the setting field name
      values - the valid enum values (for error messages)
      parser - parses the string value into the enum (should throw on invalid)
      errors - the exception to accumulate errors into
    • validateInt

      public static void validateInt(Map<String,Object> settings, Map<String,Object> result, String field, int min, int max, ValidationException errors)
      Validates that a setting value is an integer within the given range. If present and valid, the parsed integer is added to the result map.
      Parameters:
      settings - the raw settings map
      result - the validated result map to add to
      field - the setting field name
      min - minimum allowed value (inclusive)
      max - maximum allowed value (inclusive)
      errors - the exception to accumulate errors into