changes in function PetName

This commit is contained in:
dangerbaldo 2024-03-27 22:03:56 +01:00
parent c61cb84a0f
commit 0ee9f222db

View file

@ -134,8 +134,6 @@ class PetController {
public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model, public String processUpdateForm(@Valid Pet pet, BindingResult result, Owner owner, ModelMap model,
RedirectAttributes redirectAttributes) { RedirectAttributes redirectAttributes) {
//adding new features....
String petName = pet.getName(); String petName = pet.getName();
// checking if the pet name already exist for the owner // checking if the pet name already exist for the owner
@ -145,6 +143,7 @@ class PetController {
result.rejectValue("name", "duplicate", "already exists"); result.rejectValue("name", "duplicate", "already exists");
} }
} }
LocalDate currentDate = LocalDate.now(); LocalDate currentDate = LocalDate.now();
if (pet.getBirthDate() != null && pet.getBirthDate().isAfter(currentDate)) { if (pet.getBirthDate() != null && pet.getBirthDate().isAfter(currentDate)) {
result.rejectValue("birthDate", "typeMismatch.birthDate"); result.rejectValue("birthDate", "typeMismatch.birthDate");