Package com.cloudforge.core.config
Interface FieldValidator
- All Known Implementing Classes:
CapacityValidator,FargateCpuMemoryValidator
public interface FieldValidator
Custom validator for configuration field cross-field validation.
Validators enable complex validation logic that depends on multiple fields or external state. They are executed after basic field-level validation (required, min, max, allowedValues, pattern).
Built-in Validators:
CapacityValidator- Validates maxCapacity >= minCapacityFargateCpuMemoryValidator- Validates AWS Fargate CPU/memory combinations
Usage in Annotations:
@ConfigField(
displayName = "Maximum Capacity",
validators = {"CapacityValidator"}
)
public int maxCapacity = 10;
Implementing Custom Validators:
public class CustomValidator implements FieldValidator {
@Override
public ValidationResult validate(
ConfigFieldInfo field,
Object value,
Object config
) {
// Access other fields via reflection
// Return ValidationResult.ok() or ValidationResult.error(message)
}
}
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvalidate(ConfigFieldInfo field, Object value, Object config) Validates a field value in the context of the complete configuration.
-
Method Details
-
validate
Validates a field value in the context of the complete configuration.- Parameters:
field- metadata about the field being validatedvalue- the value to validateconfig- the complete configuration object (allows accessing other fields)- Returns:
- validation result (ok or error with message)
-