[R1] Add validation for entity class as well
This commit is contained in:
parent
0acd40135d
commit
f4543b678c
@ -4,6 +4,7 @@ import com.mirna.hospitalmanagementapi.domain.dtos.AddressDTO;
|
||||
import com.mirna.hospitalmanagementapi.domain.dtos.DoctorDTO;
|
||||
|
||||
import jakarta.persistence.Embeddable;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -32,12 +33,23 @@ public class Address {
|
||||
this.houseNumber = addressDTO.houseNumber();
|
||||
}
|
||||
|
||||
@NotBlank(message="street cannot be blank")
|
||||
private String street;
|
||||
|
||||
@NotBlank(message="neighborhood cannot be blank")
|
||||
private String neighborhood;
|
||||
|
||||
@NotBlank(message="zipCode cannot be blank")
|
||||
private String zipCode;
|
||||
|
||||
@NotBlank(message="city cannot be blank")
|
||||
private String city;
|
||||
|
||||
@NotBlank(message="state cannot be blank")
|
||||
private String state;
|
||||
|
||||
private String additionalDetails;
|
||||
|
||||
private String houseNumber;
|
||||
|
||||
/**
|
||||
|
||||
@ -11,6 +11,8 @@ import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -34,17 +36,29 @@ public class Doctor {
|
||||
this.specialty=doctorDTO.specialty();
|
||||
this.address = new Address(doctorDTO.address());
|
||||
}
|
||||
|
||||
public Doctor(){}
|
||||
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message="name cannot be blank")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message="email cannot be blank")
|
||||
private String email;
|
||||
|
||||
@NotBlank(message="crm cannot be blank")
|
||||
private String crm;
|
||||
|
||||
@NotBlank(message="telephone cannot be blank")
|
||||
private String telephone;
|
||||
|
||||
@NotNull(message="specialty cannot be null")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private Specialty specialty;
|
||||
|
||||
@NotNull(message="address cannot be null")
|
||||
@Embedded
|
||||
private Address address;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user