What is global error (in spring validation)?

2.8k views Asked by At

I'm checking spring-validation Errors(BindingResult) interface. It mentions global errors in contrast with field erros. What are global errors?

1

There are 1 answers

0
laffuste On

FieldError (javadoc)

  • registered via rejectValue (javadoc)

  • attached to a field

    Example:

    errors.rejectValue("name", "name.empty", "cannot be empty")`
    

ObjectError (global error) (javadoc)

  • registered via reject (javadoc)

  • not attached to a specific field (either multifield or not field related)

    Examples:

    errors.reject("password.mismatch", "Password doesn't match confirm password")
    errors.reject("optimistic.out-out-date", "This page has been saved in the meantime. Reload it and start editing it again")