Class DataSourceValidationUtils
java.lang.Object
org.elasticsearch.xpack.esql.datasources.spi.DataSourceValidationUtils
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 Summary
Modifier and TypeMethodDescriptionstatic voidrejectUnknownFields(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.static <E extends Enum<E>>
voidvalidateEnum(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.static voidvalidateInt(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.
-
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 checkknownFields- the set of valid field nameserrors- 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 byDataSourceConfigDefinition.caseInsensitive()in the configuration layer.- Parameters:
settings- the raw settings mapresult- the validated result map to add tofield- the setting field namevalues- 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 mapresult- the validated result map to add tofield- the setting field namemin- minimum allowed value (inclusive)max- maximum allowed value (inclusive)errors- the exception to accumulate errors into
-