[R1] Add validation annotation for address and doctor dtos
This commit is contained in:
parent
3e30913233
commit
ed81548b45
@ -1,5 +1,27 @@
|
|||||||
package com.mirna.hospitalmanagementapi.domain.dtos;
|
package com.mirna.hospitalmanagementapi.domain.dtos;
|
||||||
|
|
||||||
public record AddressDTO(String street, String neighborhood, String zipCode, String city, String state,
|
import jakarta.validation.constraints.NotBlank;
|
||||||
String additionalDetails, String houseNumber) {
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
|
||||||
|
public record AddressDTO(
|
||||||
|
|
||||||
|
@NotBlank(message="street cannot be blank")
|
||||||
|
String street,
|
||||||
|
|
||||||
|
@NotBlank(message="neighborhood cannot be blank")
|
||||||
|
String neighborhood,
|
||||||
|
|
||||||
|
@NotBlank(message="zipCode cannot be blank")
|
||||||
|
@Pattern(regexp="\\d{8}", message="invalid format for zipCode")
|
||||||
|
String zipCode,
|
||||||
|
|
||||||
|
@NotBlank(message="city cannot be blank")
|
||||||
|
String city,
|
||||||
|
|
||||||
|
@NotBlank(message="state cannot be blank")
|
||||||
|
String state,
|
||||||
|
|
||||||
|
String additionalDetails,
|
||||||
|
|
||||||
|
String houseNumber) {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,34 @@ package com.mirna.hospitalmanagementapi.domain.dtos;
|
|||||||
|
|
||||||
import com.mirna.hospitalmanagementapi.domain.enums.Speciality;
|
import com.mirna.hospitalmanagementapi.domain.enums.Speciality;
|
||||||
|
|
||||||
public record DoctorDTO(String name, String email, String crm, String telephone, Speciality speciality, AddressDTO addressDTO) {
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.Email;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.Pattern;
|
||||||
|
|
||||||
|
public record DoctorDTO(
|
||||||
|
|
||||||
|
@NotBlank(message="name cannot be blank")
|
||||||
|
String name,
|
||||||
|
|
||||||
|
@NotBlank(message="email cannot be blank")
|
||||||
|
@Email(message="invalid format for email")
|
||||||
|
String email,
|
||||||
|
|
||||||
|
@NotBlank(message="crm cannot be blank")
|
||||||
|
@Pattern(regexp = "\\d{4,6}", message="invalid format for crm")
|
||||||
|
String crm,
|
||||||
|
|
||||||
|
@NotBlank(message="telephone cannot be blank")
|
||||||
|
String telephone,
|
||||||
|
|
||||||
|
@NotNull(message="speciality cannot be null")
|
||||||
|
@Valid
|
||||||
|
Speciality speciality,
|
||||||
|
|
||||||
|
@NotNull(message="address cannot be null")
|
||||||
|
@Valid
|
||||||
|
AddressDTO address) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user