spring-projects / spring-projects/spring-data-rest

Validator docs are silent on when validators run and implications to developers [DATAREST-789]

Open
#1,161 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug type: documentation
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Marc Zampetti opened DATAREST-789 and commented

In the SDR docs, the section on Validators and Events is silent on when the various events/validations fire to an extent. There is docs about the various types of events, but it is not clear specifically when those events are fired in the overall lifecycle.

This can lead to confusion for developers, especially in the case of the BeforeSave() event. For example, when writing a BeforeSave validator that inspects the input Object, in the case of a PATCH request that is given a partial object, the Validator is run against the input object, and NOT the merged object. But the docs don't make that clear, and so its reasonable that a developer might assume the validation is run later. This can lead to problems since the validator might be trying to enforce validation rules that are not valid in the case of a partial object.

The docs should be updated to be more clear about when the event fires, and on what type of object the various events are applied against


Affects: 2.3.2 (Fowler SR2), 2.4.2 (Gosling SR2), 2.4.4 (Gosling SR4), 2.5 RC1 (Hopper)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.