Description
While working on T372952: (stretch) xLab: Add better validation to forms some pending work was considered as a follow up task. That's the case of a validation rule to check whether an existing instrument or experiment has already the same name or slug that the one the user is registering or updating.
One way to implement this would be using our own instrumentService.findInstrument function to check if there is already an instrument/experiment with the given name/slug but it seems we cannot use that service because it's using, indirectly, the fs node library (to load the config file where database configuration resides) which is not available in the browser where the frontend is executed while validating the form. That approach is causing problems when building xLab.
A workaround would be creating a util function to make a simple request to GET /instrument/slug but we don't have anything similar with the name. Is there any other valid approach?
We also have to determine is we want to check this only for the instrument/experiment name or also for the slug, because when we define the validation rules the slug for instruments/experiments was generated automatically but now it's filled by the user manually so I guess we should check same thing for that field
Acceptance Criteria
- Determine when we need to check if an existing instrument or experiment has the same name or slug
- xLab validates whether a name/slug are already used by an existing instrument/experiment when registering a new one
- xLab validates whether a name/slug are already used by another existing instrument/experiment when updating an existing one