Skip to content

Commit

Permalink
Add validations for lists
Browse files Browse the repository at this point in the history
  • Loading branch information
romanstrobl committed Dec 20, 2024
1 parent 9e57234 commit 2b59d9e
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class AddActivationFlagsRequest {

@Schema(description = "List of activation flags")
@NotEmpty(message = "List of activation flags must not be empty when adding activation flags")
private List<String> activationFlags = new ArrayList<>();
private List<@NotBlank String> activationFlags = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class AddApplicationRolesRequest {

@Schema(description = "Application roles")
@NotEmpty(message = "List of application roles must not be empty when adding application roles")
private List<String> applicationRoles = new ArrayList<>();
private List<@NotBlank String> applicationRoles = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package com.wultra.security.powerauth.client.model.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

/**
Expand All @@ -31,11 +31,11 @@
public class CommitUpgradeRequest {

@Schema(description = "Activation identifier")
@NotEmpty(message = "Activation ID must not be empty when committing upgrade")
@NotBlank(message = "Activation ID must not be empty when committing upgrade")
private String activationId;

@Schema(description = "Application key")
@NotEmpty(message = "Application key must not be empty when committing upgrade")
@NotBlank(message = "Application key must not be empty when committing upgrade")
private String applicationKey;

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class CreateCallbackUrlRequest {
private String callbackUrl;

@Schema(description = "Callback attributes")
private List<String> attributes = new ArrayList<>();
private List<@NotBlank String> attributes = new ArrayList<>();

@Schema(description = "Callback authentication")
private HttpAuthenticationPrivate authentication = new HttpAuthenticationPrivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ public class InitActivationRequest {
private String activationOtp;

@Schema(description = "List of activation flags")
private List<String> flags = new ArrayList<>();
private List<@NotBlank String> flags = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.wultra.security.powerauth.client.model.enumeration.ActivationStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

Expand All @@ -37,10 +38,10 @@ public class LookupActivationsRequest {

@Schema(description = "User identifiers")
@NotEmpty(message = "List of user identifiers must not be empty when requesting activations lookup")
private List<String> userIds = new ArrayList<>();
private List<@NotBlank String> userIds = new ArrayList<>();

@Schema(description = "Application identifiers")
private List<String> applicationIds = new ArrayList<>();
private List<@NotBlank String> applicationIds = new ArrayList<>();

@Schema(description = "Timestamp last used before specified timestamp")
private Date timestampLastUsedBefore;
Expand All @@ -52,6 +53,6 @@ public class LookupActivationsRequest {
private ActivationStatus activationStatus;

@Schema(description = "List of activation flags")
private List<String> activationFlags = new ArrayList<>();
private List<@NotBlank String> activationFlags = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class OperationCreateRequest {
@Schema(description = "List of associated applications")
@NotNull(message = "Application ID list must not be null when creating operation")
@Size(min = 1, message = "Application ID list must not be empty when creating operation")
private List<String> applications = new ArrayList<>();
private List<@NotBlank String> applications = new ArrayList<>();

@Schema(description = "Activation flag associated with the operation")
private String activationFlag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class OperationExtIdRequest {
@Schema(description = "Associated application identifiers")
@NotNull(message = "Application ID list must not be null when requesting operation lookup by external ID")
@Size(min = 1, message = "Application ID list must not be empty when requesting operation lookup by external ID")
private List<String> applications = new ArrayList<>();
private List<@NotBlank String> applications = new ArrayList<>();

@Min(0)
private Integer pageNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class OperationListForUserRequest {
@Schema(description = "Associated application identifiers")
@NotNull(message = "Application ID list must not be null when requesting operation list")
@Size(min = 1, message = "Application ID list must not be empty when requesting operation list")
private List<String> applications = new ArrayList<>();
private List<@NotBlank String> applications = new ArrayList<>();

@Min(0)
private Integer pageNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class OperationTemplateCreateRequest {
@JsonSetter(nulls = Nulls.SKIP)
@Schema(description = "Allowed signature types")
@NotEmpty(message = "Template signature types must contain at least one value")
private final List<SignatureType> signatureType = new ArrayList<>();
private final List<@NotBlank SignatureType> signatureType = new ArrayList<>();

/**
* How many failed attempts should be allowed for the operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class OperationTemplateUpdateRequest {
@Schema(description = "Allowed signature types")
@NotEmpty(message = "Template signature types must contain at least one value")
@JsonSetter(nulls = Nulls.SKIP)
private final List<SignatureType> signatureType = new ArrayList<>();
private final List<@NotBlank SignatureType> signatureType = new ArrayList<>();

@Schema(description = "How many failed attempts should be allowed for the operation")
@NotNull(message = "Template expiration value must not be null when updating operation template")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class RemoveActivationFlagsRequest {

@Schema(description = "List of activation flags")
@NotEmpty(message = "List of activation flags must not be empty when removing activation flags")
private List<String> activationFlags = new ArrayList<>();
private List<@NotBlank String> activationFlags = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class RemoveApplicationRolesRequest {

@Schema(description = "Application roles")
@NotEmpty(message = "List of application roles must not be empty when removing application roles")
private List<String> applicationRoles = new ArrayList<>();
private List<@NotBlank String> applicationRoles = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.wultra.security.powerauth.client.model.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;

Expand All @@ -35,6 +36,6 @@ public class RevokeRecoveryCodesRequest {

@Schema(description = "List of recovery code identifiers")
@NotEmpty(message = "List of recovery code identifiers must not be empty when revoking recovery codes")
private List<Long> recoveryCodeIds = new ArrayList<>();
private List<@NotBlank Long> recoveryCodeIds = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class UpdateActivationFlagsRequest {

@Schema(description = "List of activation flags")
@NotNull(message = "List of activation flags must not be null when updating activation flags")
private List<String> activationFlags = new ArrayList<>();
private List<@NotBlank String> activationFlags = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public class UpdateApplicationRolesRequest {

@Schema(description = "Application roles")
@NotEmpty(message = "List of application roles must not be empty when updating application roles")
private List<String> applicationRoles = new ArrayList<>();
private List<@NotBlank String> applicationRoles = new ArrayList<>();

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class UpdateCallbackUrlRequest {
private String callbackUrl;

@Schema(description = "Callback attributes")
private List<String> attributes = new ArrayList<>();
private List<@NotBlank String> attributes = new ArrayList<>();

@Schema(description = "Callback authentication")
private HttpAuthenticationPrivate authentication = new HttpAuthenticationPrivate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.wultra.security.powerauth.client.model.enumeration.ActivationStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
Expand All @@ -37,7 +38,7 @@ public class UpdateStatusForActivationsRequest {

@Schema(description = "Activation identifiers")
@NotEmpty(message = "List of activation identifiers must not be empty when updating activation status")
private List<String> activationIds = new ArrayList<>();
private List<@NotBlank String> activationIds = new ArrayList<>();

@Schema(description = "Activation status")
@NotNull(message = "Activation status must not be empty when updating activation status")
Expand Down

0 comments on commit 2b59d9e

Please sign in to comment.