Skip to content

A server-side validation error removes the field's own validators (e.g. required) #6335

Description

@kanasznagyzoltan

Describe the bug

When the REST API reports a validation error for a form field, FormService.addErrorToField() keeps the error in place with setValidators(), which replaces all validators of the field. removeErrorFromField() then calls clearValidators(). From then on the field has lost its own validators, such as required, so the client no longer flags it.

Seen on DSpace10.0; the same code is on main.

To Reproduce

  1. Start a new submission and leave a required field (e.g. Title) empty.
  2. Click "Deposit": the server-side error is shown on the field.
  3. Enter a value: the error goes away.
  4. Clear the field again: no "required" error is shown on the client any more.

Expected behavior

After a server-side error has been removed, the field still has its own validators, and clearing a required field shows the "required" error again.

Related work

Link to any related tickets or PRs here.

Metadata

Metadata

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions