mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
refactor: build every not-null violation with SmithyValidationErrors.notNull (#6439)
Twenty-six files in 19 services, and TagDispatcher, spelled out AWS's framework sentence for a missing required member, "Value null at '<path>' failed to satisfy constraint: Member must not be null", which SmithyValidationErrors.notNull has built since #6261. They now call it. The three that also wrote the "1 validation error detected: " count in front, Auto Scaling's missing granularity, STS's required parameters and SWF's missingRequired, build the whole message with SmithyValidationErrors.message, and EMR Serverless's private copy of notNull is gone. Every message stays as it was. Left as they are, being other wordings: "Value at '...'" without "null" (Cognito's accessToken, SES, KMS's sensitive members), the variants ending in a period in Cost Explorer, CUR, BCM Data Exports and Pricing, Lambda's "Value 'null'", sentences that go on ("when S3BackupMode is Enabled", "or a value must be specified for"), nested constraints, and local helpers that take any constraint's text.
This commit is contained in:
1 parent
b36fd2f0be
commit
998276b8f5
27 files changed
+67
-93
No files matched your search
@@ -136,7 +136,7 @@ public class TagDispatcher {
|
||||
if (tagNode == null || tagNode.isNull()) {
|
||||
if (handler.strictTagValidation()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at '" + key + "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(key));
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class TagDispatcher {
|
||||
if (handler.strictTagValidation() && !handler.allowEmptyTagKeys()
|
||||
&& (values == null || values.isEmpty())) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at '" + paramName + "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(paramName));
|
||||
}
|
||||
return (values == null) ? List.of() : List.copyOf(values);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class AcmJsonHandler {
|
||||
if (domainName == null || domainName.isBlank()) {
|
||||
return Response.status(400)
|
||||
.entity(new AwsErrorResponse("ValidationException",
|
||||
"Value null at 'domainName' failed to satisfy constraint: Member must not be null"))
|
||||
SmithyValidationErrors.notNull("domainName")))
|
||||
.build();
|
||||
}
|
||||
JsonNode sanNode = request.path("SubjectAlternativeNames");
|
||||
|
||||
+2
-4
@@ -2002,8 +2002,7 @@ public class AutoScalingQueryHandler {
|
||||
}
|
||||
if (deviceName == null || deviceName.isBlank()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at '" + prefix
|
||||
+ ".DeviceName' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(prefix + ".DeviceName"));
|
||||
}
|
||||
LaunchConfigurationBlockDeviceMapping mapping = new LaunchConfigurationBlockDeviceMapping();
|
||||
mapping.setDeviceName(deviceName);
|
||||
@@ -2080,8 +2079,7 @@ public class AutoScalingQueryHandler {
|
||||
String val = p.getFirst(key);
|
||||
if (val == null || val.isBlank()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at '" + key
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(key));
|
||||
}
|
||||
if (!"true".equalsIgnoreCase(val) && !"false".equalsIgnoreCase(val)) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
|
||||
+2
-4
@@ -107,8 +107,7 @@ public class AutoScalingService implements PassedRoleLookup {
|
||||
"GroupAndWarmPoolDesiredCapacity", "GroupAndWarmPoolTotalCapacity");
|
||||
public static final String METRICS_GRANULARITY = "1Minute";
|
||||
static final String MISSING_GRANULARITY_MESSAGE =
|
||||
"1 validation error detected: Value null at 'granularity' failed to satisfy constraint: "
|
||||
+ "Member must not be null";
|
||||
SmithyValidationErrors.message(List.of(SmithyValidationErrors.notNull("granularity")));
|
||||
public static final String INVALID_GRANULARITY_MESSAGE =
|
||||
"Granularity must be 1Minute. 1Minute is the only valid value.";
|
||||
static final String ACTIVE_INSTANCE_REFRESH_DESIRED_CONFIGURATION_MESSAGE =
|
||||
@@ -1200,8 +1199,7 @@ public class AutoScalingService implements PassedRoleLookup {
|
||||
private static void validateLifecycleHookName(String hookName) {
|
||||
if (hookName == null) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at 'lifecycleHookName' failed to satisfy constraint: "
|
||||
+ "Member must not be null");
|
||||
SmithyValidationErrors.notNull("lifecycleHookName"));
|
||||
}
|
||||
if (hookName.length() > 255) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
|
||||
+1
-1
@@ -1414,7 +1414,7 @@ public class CloudFormationService implements ResourceProvider {
|
||||
private static void validateContinueUpdateRollback(String stackNameOrArn, List<String> resourcesToSkip) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
if (stackNameOrArn == null) {
|
||||
violations.add("Value null at 'stackName' failed to satisfy constraint: Member must not be null");
|
||||
violations.add(SmithyValidationErrors.notNull("stackName"));
|
||||
} else {
|
||||
if (stackNameOrArn.isEmpty()) {
|
||||
violations.add("Value '' at 'stackName' failed to satisfy constraint:"
|
||||
|
||||
@@ -1367,8 +1367,7 @@ public class CloudFrontService implements ServerCertificateReferenceProvider {
|
||||
}
|
||||
|
||||
private static String nullViolation(String member) {
|
||||
return "Value null at 'originAccessControlConfig." + member
|
||||
+ "' failed to satisfy constraint: Member must not be null";
|
||||
return SmithyValidationErrors.notNull("originAccessControlConfig." + member);
|
||||
}
|
||||
|
||||
/** The kinds of Lambda origin CloudFront tells apart. */
|
||||
|
||||
@@ -2032,7 +2032,7 @@ public class CognitoService implements ResourceProvider {
|
||||
private void validateLogConfigurations(List<Map<String, Object>> configs) {
|
||||
if (configs == null) {
|
||||
throw validationErrors(List.of(
|
||||
"Value null at 'logConfigurations' failed to satisfy constraint: Member must not be null"));
|
||||
SmithyValidationErrors.notNull("logConfigurations")));
|
||||
}
|
||||
|
||||
List<String> errors = new ArrayList<>();
|
||||
|
||||
+2
-3
@@ -220,9 +220,8 @@ public class CognitoIdentityJsonHandler {
|
||||
private boolean requiredBool(JsonNode node, String field) {
|
||||
Boolean value = bool(node, field);
|
||||
if (value == null) {
|
||||
throw SmithyValidationErrors.validationException("Value null at '"
|
||||
+ Character.toLowerCase(field.charAt(0)) + field.substring(1)
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
throw SmithyValidationErrors.validationException(
|
||||
SmithyValidationErrors.notNull(Character.toLowerCase(field.charAt(0)) + field.substring(1)));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -802,8 +802,7 @@ public class DynamoDbService {
|
||||
private static void requireVectorIndexMember(Object value, String memberPath) {
|
||||
if (value == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at '" + memberPath
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(memberPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class DynamoDbTableNames {
|
||||
private static ResolvedTableRef resolveInternal(String input) {
|
||||
if (input == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'tableName' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("tableName"));
|
||||
}
|
||||
if (input.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
|
||||
+13
-16
@@ -317,9 +317,10 @@ public class NativeDynamoDbJsonHandler {
|
||||
// projection type check. A null NonKeyAttributes counts as not specified.
|
||||
private static String requireIndexName(JsonNode node, String memberPath) {
|
||||
JsonNode indexNameNode = node.path("IndexName");
|
||||
String constraint = " at '" + memberPath + ".indexName' failed to satisfy constraint: ";
|
||||
String path = memberPath + ".indexName";
|
||||
String constraint = " at '" + path + "' failed to satisfy constraint: ";
|
||||
if (indexNameNode.isMissingNode() || indexNameNode.isNull()) {
|
||||
throwValidationErrors(List.of("Value null" + constraint + "Member must not be null"));
|
||||
throwValidationErrors(List.of(SmithyValidationErrors.notNull(path)));
|
||||
}
|
||||
String indexName = indexNameNode.asText();
|
||||
String value = "Value '" + indexName + "'" + constraint;
|
||||
@@ -353,9 +354,7 @@ public class NativeDynamoDbJsonHandler {
|
||||
JsonNode vectorAttribute = node.path("VectorAttribute");
|
||||
if (vectorAttribute.isObject() && !vectorAttribute.hasNonNull("AttributeName")) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at '" + memberPath
|
||||
+ ".vectorAttribute.attributeName' failed to satisfy constraint: "
|
||||
+ "Member must not be null");
|
||||
SmithyValidationErrors.notNull(memberPath + ".vectorAttribute.attributeName"));
|
||||
}
|
||||
List<SearchSchemaElement> searchSchema = new ArrayList<>();
|
||||
JsonNode searchSchemaArray = node.path("SearchSchema");
|
||||
@@ -1887,8 +1886,7 @@ public class NativeDynamoDbJsonHandler {
|
||||
DynamoDbTableNames.resolveWithRegion(tableName, region);
|
||||
JsonNode spec = request.path("PointInTimeRecoverySpecification");
|
||||
if (spec.isMissingNode() || spec.isNull()) {
|
||||
throwValidationErrors(List.of("Value null at 'pointInTimeRecoverySpecification' failed to satisfy "
|
||||
+ "constraint: Member must not be null"));
|
||||
throwValidationErrors(List.of(SmithyValidationErrors.notNull("pointInTimeRecoverySpecification")));
|
||||
}
|
||||
List<String> violations = new ArrayList<>();
|
||||
JsonNode period = spec.path("RecoveryPeriodInDays");
|
||||
@@ -1902,8 +1900,8 @@ public class NativeDynamoDbJsonHandler {
|
||||
}
|
||||
JsonNode enabled = spec.path("PointInTimeRecoveryEnabled");
|
||||
if (enabled.isMissingNode() || enabled.isNull()) {
|
||||
violations.add("Value null at 'pointInTimeRecoverySpecification.pointInTimeRecoveryEnabled' failed to "
|
||||
+ "satisfy constraint: Member must not be null");
|
||||
violations.add(
|
||||
SmithyValidationErrors.notNull("pointInTimeRecoverySpecification.pointInTimeRecoveryEnabled"));
|
||||
}
|
||||
throwValidationErrors(violations);
|
||||
Integer recoveryPeriodInDays = period.isNumber() ? period.asInt() : null;
|
||||
@@ -1926,7 +1924,7 @@ public class NativeDynamoDbJsonHandler {
|
||||
JsonNode backupNameNode = request.path("BackupName");
|
||||
if (backupNameNode.isMissingNode() || backupNameNode.isNull()) {
|
||||
throwValidationErrors(List.of(
|
||||
"Value null at 'backupName' failed to satisfy constraint: Member must not be null"));
|
||||
SmithyValidationErrors.notNull("backupName")));
|
||||
}
|
||||
String backupName = backupNameNode.asText();
|
||||
throwValidationErrors(nameViolations(backupName, "backupName"));
|
||||
@@ -2199,10 +2197,10 @@ public class NativeDynamoDbJsonHandler {
|
||||
}
|
||||
for (String member : List.of("WriteCapacityUnits", "ReadCapacityUnits")) {
|
||||
JsonNode value = throughput.path(member);
|
||||
String constraint = " at '" + memberPath + "." + Character.toLowerCase(member.charAt(0))
|
||||
+ member.substring(1) + "' failed to satisfy constraint: ";
|
||||
String path = memberPath + "." + Character.toLowerCase(member.charAt(0)) + member.substring(1);
|
||||
String constraint = " at '" + path + "' failed to satisfy constraint: ";
|
||||
if (value.isMissingNode() || value.isNull()) {
|
||||
violations.add("Value null" + constraint + "Member must not be null");
|
||||
violations.add(SmithyValidationErrors.notNull(path));
|
||||
} else if (value.asLong() < 1) {
|
||||
violations.add("Value '" + value.asText() + "'" + constraint
|
||||
+ "Member must have value greater than or equal to 1");
|
||||
@@ -2215,7 +2213,7 @@ public class NativeDynamoDbJsonHandler {
|
||||
private static List<String> restoreIndexNameViolations(JsonNode indexName, String memberPath) {
|
||||
String constraint = " at '" + memberPath + "' failed to satisfy constraint: ";
|
||||
if (indexName.isMissingNode() || indexName.isNull()) {
|
||||
return List.of("Value null" + constraint + "Member must not be null");
|
||||
return List.of(SmithyValidationErrors.notNull(memberPath));
|
||||
}
|
||||
String value = "Value '" + indexName.asText() + "'" + constraint;
|
||||
List<String> violations = new ArrayList<>();
|
||||
@@ -2668,8 +2666,7 @@ public class NativeDynamoDbJsonHandler {
|
||||
}
|
||||
if (!request.hasNonNull("Policy")) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'policy' failed to satisfy constraint: "
|
||||
+ "Member must not be null");
|
||||
SmithyValidationErrors.notNull("policy"));
|
||||
}
|
||||
String policy = request.path("Policy").asText();
|
||||
String expectedRevisionId = request.has("ExpectedRevisionId")
|
||||
|
||||
@@ -1462,8 +1462,8 @@ public class EcsJsonHandler {
|
||||
}
|
||||
if (!node.hasNonNull("type")) {
|
||||
throw SmithyValidationErrors.exception("ClientException",
|
||||
"Value null at 'containerDefinitions." + containerIndex
|
||||
+ ".member.firelensConfiguration.type' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("containerDefinitions." + containerIndex
|
||||
+ ".member.firelensConfiguration.type"));
|
||||
}
|
||||
String type = node.path("type").asText();
|
||||
if (!"fluentd".equals(type) && !"fluentbit".equals(type)) {
|
||||
|
||||
+4
-7
@@ -444,10 +444,10 @@ public class EmrServerlessJobRunService {
|
||||
private static void validate(StartJobRunRequest request) {
|
||||
List<String> violations = new ArrayList<>();
|
||||
if (request.getClientToken() == null) {
|
||||
violations.add(notNull("clientToken"));
|
||||
violations.add(SmithyValidationErrors.notNull("clientToken"));
|
||||
}
|
||||
if (request.getExecutionRoleArn() == null) {
|
||||
violations.add(notNull("executionRoleArn"));
|
||||
violations.add(SmithyValidationErrors.notNull("executionRoleArn"));
|
||||
} else if (!ROLE_ARN.matcher(request.getExecutionRoleArn()).matches()) {
|
||||
violations.add("Value at 'executionRoleArn' failed to satisfy constraint: "
|
||||
+ "Member must satisfy regular expression pattern: " + ROLE_ARN_PATTERN);
|
||||
@@ -464,10 +464,10 @@ public class EmrServerlessJobRunService {
|
||||
}
|
||||
JobDriver driver = request.getJobDriver();
|
||||
if (driver != null && driver.getSparkSubmit() != null && driver.getSparkSubmit().getEntryPoint() == null) {
|
||||
violations.add(notNull("jobDriver.sparkSubmit.entryPoint"));
|
||||
violations.add(SmithyValidationErrors.notNull("jobDriver.sparkSubmit.entryPoint"));
|
||||
}
|
||||
if (driver != null && driver.getHive() != null && driver.getHive().getQuery() == null) {
|
||||
violations.add(notNull("jobDriver.hive.query"));
|
||||
violations.add(SmithyValidationErrors.notNull("jobDriver.hive.query"));
|
||||
}
|
||||
if (!violations.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(violations);
|
||||
@@ -480,9 +480,6 @@ public class EmrServerlessJobRunService {
|
||||
}
|
||||
}
|
||||
|
||||
private static String notNull(String member) {
|
||||
return "Value null at '" + member + "' failed to satisfy constraint: Member must not be null";
|
||||
}
|
||||
|
||||
/**
|
||||
* From Amazon EMR release 7.11.0 a BATCH run's timeout is 1 to 10080 minutes; an earlier release, or
|
||||
|
||||
@@ -1452,7 +1452,7 @@ public class IamQueryHandler {
|
||||
String description = params.getFirst("Description");
|
||||
if (description == null) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at 'description' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("description"));
|
||||
}
|
||||
IamRole role = iamService.updateRoleDescription(getParam(params, "RoleName"), description);
|
||||
String result = new XmlBuilder().start("Role").raw(roleXml(role, true)).end("Role").build();
|
||||
@@ -3587,9 +3587,7 @@ public class IamQueryHandler {
|
||||
String value = params.getFirst(name);
|
||||
if (value == null || value.isBlank()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at '"
|
||||
+ Character.toLowerCase(name.charAt(0)) + name.substring(1)
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(Character.toLowerCase(name.charAt(0)) + name.substring(1)));
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -2858,8 +2858,7 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
private static void validatePassword(String password, String member) {
|
||||
if (password == null) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at '" + member
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(member));
|
||||
}
|
||||
if (!LOGIN_PROFILE_PASSWORD_PATTERN.matcher(password).matches()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
@@ -2932,8 +2931,7 @@ public class IamService implements SessionAccountLookup, ResourceProvider {
|
||||
public void putAccountProperties(Map<String, String> properties) {
|
||||
if (properties == null || properties.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationError(
|
||||
"Value null at 'properties' failed to "
|
||||
+ "satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("properties"));
|
||||
}
|
||||
String namespace = null;
|
||||
for (Map.Entry<String, String> entry : properties.entrySet()) {
|
||||
|
||||
@@ -918,8 +918,7 @@ public class StsQueryHandler {
|
||||
String value = params.getFirst(name);
|
||||
if (value == null || value.isBlank()) {
|
||||
return AwsQueryResponse.error("ValidationError",
|
||||
"1 validation error detected: Value null at '" + name
|
||||
+ "' failed to satisfy constraint: Member must not be null",
|
||||
SmithyValidationErrors.message(List.of(SmithyValidationErrors.notNull(name))),
|
||||
AwsNamespaces.STS, 400);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public class IotFleetIndexingService {
|
||||
String nextToken = text(request.path("nextToken"), "nextToken");
|
||||
List<String> errors = new ArrayList<>();
|
||||
if (queryString == null) {
|
||||
errors.add("Value null at 'queryString' failed to satisfy constraint: Member must not be null");
|
||||
errors.add(SmithyValidationErrors.notNull("queryString"));
|
||||
} else if (queryString.isEmpty()) {
|
||||
errors.add("Value '' at 'queryString' failed to satisfy constraint: "
|
||||
+ "Member must have length greater than or equal to 1");
|
||||
@@ -468,8 +468,7 @@ public class IotFleetIndexingService {
|
||||
String value = text(node.path(member), prefix + "." + member);
|
||||
if (value == null) {
|
||||
if (required) {
|
||||
errors.add("Value null at '" + prefix + "." + member
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
errors.add(SmithyValidationErrors.notNull(prefix + "." + member));
|
||||
}
|
||||
return "OFF";
|
||||
}
|
||||
|
||||
@@ -829,8 +829,7 @@ public class KmsJsonHandler {
|
||||
String name = Character.toLowerCase(member.charAt(0)) + member.substring(1);
|
||||
JsonNode value = request.path(member);
|
||||
if (value.isMissingNode() || value.isNull()) {
|
||||
throw SmithyValidationErrors.validationException("Value null at '" + name
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
throw SmithyValidationErrors.validationException(SmithyValidationErrors.notNull(name));
|
||||
}
|
||||
String keyId = value.asText();
|
||||
String pattern = "Value '" + keyId + "' at '" + name
|
||||
|
||||
@@ -2006,8 +2006,7 @@ public class KmsService implements ResourceProvider {
|
||||
private static void validateEnumMember(String member, String value, List<String> allowed) {
|
||||
if (value == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at '" + member + "' failed to satisfy "
|
||||
+ "constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(member));
|
||||
}
|
||||
if (!allowed.contains(value)) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
|
||||
@@ -409,8 +409,7 @@ public class LambdaLayerService {
|
||||
public LambdaLayerVersion getLayerVersionByArn(String layerVersionArn) {
|
||||
if (layerVersionArn == null || layerVersionArn.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'arn' failed to satisfy constraint: "
|
||||
+ "Member must not be null");
|
||||
SmithyValidationErrors.notNull("arn"));
|
||||
}
|
||||
if (layerVersionArn.length() > MAX_LAYER_VERSION_ARN_LENGTH
|
||||
|| !LAYER_VERSION_ARN.matcher(layerVersionArn).matches()) {
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ final class LambdaWebValidation {
|
||||
/** A member read by {@link LambdaWebJson}, so an absent JSON member arrives as null. */
|
||||
LambdaWebValidation required(String path, Object value) {
|
||||
if (value == null) {
|
||||
errors.add("Value null at '" + path + "' failed to satisfy constraint: Member must not be null");
|
||||
errors.add(SmithyValidationErrors.notNull(path));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ public class SchedulerService {
|
||||
private void validateScheduleRequest(ScheduleRequest req) {
|
||||
if (req.getScheduleExpression() == null || req.getScheduleExpression().isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'scheduleExpression' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("scheduleExpression"));
|
||||
}
|
||||
if (req.getScheduleExpression().length() > 256) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
@@ -366,12 +366,12 @@ public class SchedulerService {
|
||||
}
|
||||
if (req.getFlexibleTimeWindow() == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'flexibleTimeWindow' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("flexibleTimeWindow"));
|
||||
}
|
||||
String flexibleTimeWindowMode = req.getFlexibleTimeWindow().getMode();
|
||||
if (flexibleTimeWindowMode == null || flexibleTimeWindowMode.isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'flexibleTimeWindow.mode' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("flexibleTimeWindow.mode"));
|
||||
}
|
||||
flexibleTimeWindowMode = flexibleTimeWindowMode.trim();
|
||||
if (!"OFF".equals(flexibleTimeWindowMode) && !"FLEXIBLE".equals(flexibleTimeWindowMode)) {
|
||||
@@ -381,7 +381,7 @@ public class SchedulerService {
|
||||
if ("FLEXIBLE".equals(flexibleTimeWindowMode)
|
||||
&& req.getFlexibleTimeWindow().getMaximumWindowInMinutes() == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'flexibleTimeWindow.maximumWindowInMinutes' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("flexibleTimeWindow.maximumWindowInMinutes"));
|
||||
}
|
||||
if ("OFF".equals(flexibleTimeWindowMode)
|
||||
&& req.getFlexibleTimeWindow().getMaximumWindowInMinutes() != null) {
|
||||
@@ -390,15 +390,15 @@ public class SchedulerService {
|
||||
}
|
||||
if (req.getTarget() == null) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'target' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("target"));
|
||||
}
|
||||
if (req.getTarget().getArn() == null || req.getTarget().getArn().isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'target.arn' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("target.arn"));
|
||||
}
|
||||
if (req.getTarget().getRoleArn() == null || req.getTarget().getRoleArn().isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'target.roleArn' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("target.roleArn"));
|
||||
}
|
||||
if (req.getTarget().getRoleArn().length() > 1600) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
@@ -415,7 +415,7 @@ public class SchedulerService {
|
||||
&& (req.getTarget().getDeadLetterConfig().getArn() == null
|
||||
|| req.getTarget().getDeadLetterConfig().getArn().isBlank())) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'target.deadLetterConfig.arn' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("target.deadLetterConfig.arn"));
|
||||
}
|
||||
String input = req.getTarget().getInput();
|
||||
if (input != null && requiresJsonInput(req.getTarget().getArn()) && !isWellFormedJson(input)) {
|
||||
|
||||
@@ -273,8 +273,7 @@ public class SesAccountController {
|
||||
if (node.isMissingNode() || node.isNull()) {
|
||||
if (required) {
|
||||
throw SmithyValidationErrors.badRequest(
|
||||
"Value null at '" + path
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(path));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -526,8 +526,7 @@ public class SsmJsonHandler {
|
||||
String permissionType = request.path("PermissionType").asText();
|
||||
if (permissionType == null || permissionType.isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'permissionType' failed to satisfy "
|
||||
+ "constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("permissionType"));
|
||||
}
|
||||
if (!"Share".equals(permissionType)) {
|
||||
throw new AwsException("InvalidPermissionType",
|
||||
@@ -651,8 +650,7 @@ public class SsmJsonHandler {
|
||||
JsonNode contentNode = request.path("Content");
|
||||
if (!contentNode.isTextual() || contentNode.asText().isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'content' failed to satisfy "
|
||||
+ "constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("content"));
|
||||
}
|
||||
return contentNode.asText();
|
||||
}
|
||||
@@ -818,7 +816,7 @@ public class SsmJsonHandler {
|
||||
JsonNode nameNode = request.path("Name");
|
||||
if (!nameNode.isTextual() || nameNode.asText().isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'name' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("name"));
|
||||
}
|
||||
String name = nameNode.asText();
|
||||
|
||||
@@ -851,7 +849,7 @@ public class SsmJsonHandler {
|
||||
String associationId = request.hasNonNull("AssociationId") ? request.path("AssociationId").asText() : null;
|
||||
if (associationId == null || associationId.isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'associationId' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("associationId"));
|
||||
}
|
||||
|
||||
String associationName = request.hasNonNull("AssociationName") ? request.path("AssociationName").asText() : null;
|
||||
@@ -1150,12 +1148,12 @@ public class SsmJsonHandler {
|
||||
|
||||
List<String> violations = new ArrayList<>();
|
||||
if (name == null) {
|
||||
violations.add("Value null at 'name' failed to satisfy constraint: Member must not be null");
|
||||
violations.add(SmithyValidationErrors.notNull("name"));
|
||||
} else if (name.isEmpty()) {
|
||||
violations.add("Value '' at 'name' failed to satisfy constraint: Member must have length greater than or equal to 1");
|
||||
}
|
||||
if (parameterVersion == null) {
|
||||
violations.add("Value null at 'parameterVersion' failed to satisfy constraint: Member must not be null");
|
||||
violations.add(SmithyValidationErrors.notNull("parameterVersion"));
|
||||
}
|
||||
String labelViolation = SsmService.labelListViolation(labels);
|
||||
if (labelViolation != null) {
|
||||
@@ -1248,8 +1246,7 @@ public class SsmJsonHandler {
|
||||
String settingId = request.path("SettingId").asText();
|
||||
if (settingId == null || settingId.isBlank()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'settingId' failed to satisfy "
|
||||
+ "constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("settingId"));
|
||||
}
|
||||
return settingId;
|
||||
}
|
||||
@@ -1267,8 +1264,7 @@ public class SsmJsonHandler {
|
||||
String settingValue = valueNode.asText();
|
||||
if (!valueNode.isTextual() || settingValue.isEmpty()) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
"Value null at 'settingValue' failed to satisfy "
|
||||
+ "constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull("settingValue"));
|
||||
}
|
||||
if (settingValue.length() > MAX_SETTING_VALUE_LENGTH) {
|
||||
throw SmithyValidationErrors.validationException(
|
||||
|
||||
@@ -955,7 +955,7 @@ public class SsmService implements ResourceProvider {
|
||||
*/
|
||||
static String labelListViolation(List<String> labels) {
|
||||
if (labels == null) {
|
||||
return "Value null at 'labels' failed to satisfy constraint: Member must not be null";
|
||||
return SmithyValidationErrors.notNull("labels");
|
||||
}
|
||||
String prefix = "Value '" + labels + "' at 'labels' failed to satisfy constraint: ";
|
||||
if (labels.isEmpty()) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package io.github.hectorvent.floci.services.swf;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.services.swf.model.SwfConstants;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Factory for SWF faults.
|
||||
*
|
||||
@@ -123,8 +126,7 @@ final class SwfFaults {
|
||||
}
|
||||
|
||||
static AwsException missingRequired(String field) {
|
||||
return validation("1 validation error detected: Value null at '" + field
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
return validation(SmithyValidationErrors.message(List.of(SmithyValidationErrors.notNull(field))));
|
||||
}
|
||||
|
||||
static AwsException fault(String code, String message) {
|
||||
|
||||
@@ -257,8 +257,7 @@ public class TranscribeService implements Resettable {
|
||||
private void requireNonBlank(String value, String fieldName) {
|
||||
if (value == null || value.isBlank()) {
|
||||
throw SmithyValidationErrors.badRequest(
|
||||
"Value null at '" + fieldName
|
||||
+ "' failed to satisfy constraint: Member must not be null");
|
||||
SmithyValidationErrors.notNull(fieldName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user