Closed dave-mills closed 1 year ago
Need to add exception into FormRequest to ignore the current value
@ciara-mc - at the moment, the project code's validation is just using the default 'unique' rule, which is causing the issue. This rule checks the whole database for the value to be saved, and then returns a validation error because it finds an existing entry (the entry being edited).
The current rule also checks for uniqueness across the whole platform, not just within the current organisation, which is incorrect. So I think the way to fix the bug is to update the platform to use a custom rule that does what we need. The FAW data platform does this exact thing with 'teams' and 'sites' instead of 'organisations' and 'projects':
https://github.com/stats4sd/faw-data-platform/blob/dev/app/Rules/UniqueSiteCode.php
Info on custom validation rules: https://laravel.com/docs/9.x/validation#custom-validation-rules