@Override public boolean hasGlobalErrors() { return this.source.hasGlobalErrors(); }
@Override public boolean hasGlobalErrors() { return this.source.hasGlobalErrors(); }
@Test public void testNestedValidatorWithoutNestedPath() { TestBean tb = new TestBean(); tb.setName("XXX"); Errors errors = new BeanPropertyBindingResult(tb, "tb"); Validator spouseValidator = new SpouseValidator(); spouseValidator.validate(tb, errors); assertTrue(errors.hasGlobalErrors()); assertEquals(1, errors.getGlobalErrorCount()); assertEquals("SPOUSE_NOT_AVAILABLE", errors.getGlobalError().getCode()); assertEquals("tb", (errors.getGlobalErrors().get(0)).getObjectName()); }
assertTrue("Correct object name", "tb".equals(errors.getObjectName())); assertTrue("Correct global errors flag", errors.hasGlobalErrors()); assertTrue("Correct number of global errors", errors.getGlobalErrorCount() == 1); ObjectError globalError = errors.getGlobalError();
@Override protected boolean matchesSafely(Errors item) { if (code == null) { return item.hasGlobalErrors(); } else { return item.getGlobalErrors().stream().anyMatch(c -> code.equals(c.getCode())); } }
assertTrue(!errors.hasGlobalErrors()); assertEquals(1, errors.getFieldErrorCount("age")); assertTrue(!errors.hasFieldErrors("name"));
@Override public boolean hasGlobalErrors() { return this.source.hasGlobalErrors(); }
@Override public boolean hasGlobalErrors() { return this.source.hasGlobalErrors(); }
public boolean hasGlobalErrors() { return this.source.hasGlobalErrors(); }
public boolean hasGlobalErrors() { Errors errors = getErrors(); return errors != null && errors.hasGlobalErrors(); }
@PreAuthorize(SecurityRules.IS_OFFICE) @RequestMapping(value = "/department/{departmentId}", method = RequestMethod.POST) public String updateDepartment(@PathVariable("departmentId") Integer departmentId, @ModelAttribute(DepartmentConstants.DEPARTMENT_ATTRIBUTE) Department department, Errors errors, Model model, RedirectAttributes redirectAttributes) throws UnknownDepartmentException { // Check if department exists departmentService.getDepartmentById(departmentId).orElseThrow(() -> new UnknownDepartmentException(departmentId)); validator.validate(department, errors); if (errors.hasGlobalErrors()) { model.addAttribute(ControllerConstants.ERRORS_ATTRIBUTE, errors); } if (errors.hasErrors()) { List<Person> persons = getPersons(); model.addAttribute(DepartmentConstants.DEPARTMENT_ATTRIBUTE, department); model.addAttribute(PersonConstants.PERSONS_ATTRIBUTE, persons); return DepartmentConstants.DEPARTMENT_FORM_JSP; } departmentService.update(department); redirectAttributes.addFlashAttribute("updatedDepartment", department); return "redirect:/web/department/"; }
if (errors.hasGlobalErrors()) { model.addAttribute(ControllerConstants.ERRORS_ATTRIBUTE, errors);
SimpleObject fieldErrors = new SimpleObject(); if (ex.getErrors().hasGlobalErrors()) {