In the following example, the ScriptFile parameter is marked with an @Valid annotation.
What does @Valid annotation do?
Just adding to the above answer, In a web application
@valid is used where the bean to be validated is also annotated with validation annotations e.g. @NotNull, @Email(hibernate annotation) so when while getting input from user the values can be validated and binding result will have the validation results.
bindingResult.hasErrors() will tell if any validation failed.