validate pet price and species
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package com.petshop.backend.dto.chat;
|
||||
|
||||
public class MessageRequest {
|
||||
@jakarta.validation.constraints.Size(max = 10000, message = "Message content must not exceed 10000 characters")
|
||||
@jakarta.validation.constraints.Size(max = 2000, message = "Message content must not exceed 2000 characters")
|
||||
private String content;
|
||||
private String attachmentUrl;
|
||||
private String attachmentName;
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.petshop.backend.dto.pet;
|
||||
|
||||
import jakarta.validation.constraints.DecimalMax;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Positive;
|
||||
import jakarta.validation.constraints.PositiveOrZero;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -11,6 +14,7 @@ public class PetRequest {
|
||||
private String petName;
|
||||
|
||||
@NotBlank(message = "Species is required")
|
||||
@Pattern(regexp = "^(Dog|Cat|Bird|Fish|Rabbit|Hamster|Guinea Pig|Reptile|Other)$", flags = Pattern.Flag.CASE_INSENSITIVE, message = "Species must be Dog, Cat, Bird, Fish, Rabbit, Hamster, Guinea Pig, Reptile, or Other")
|
||||
private String petSpecies;
|
||||
|
||||
private String petBreed;
|
||||
@@ -21,6 +25,8 @@ public class PetRequest {
|
||||
@NotNull(message = "Status is required")
|
||||
private String petStatus;
|
||||
|
||||
@PositiveOrZero(message = "Price must be zero or positive")
|
||||
@DecimalMax(value = "99999.99", message = "Price must not exceed 99999.99")
|
||||
private BigDecimal petPrice;
|
||||
|
||||
private Long customerId;
|
||||
|
||||
Reference in New Issue
Block a user