Add validation for approvals required

What does this MR do and why?

Add validation for approvals required

Approvals required input field will work when invalid value is provided via yaml

This change improves validation for the "approvals required" field in the security policy editor. Previously, the code didn't properly validate the number of required approvals, potentially allowing invalid values. Now, it adds validation to ensure that the approvals_required value is a valid number greater than or equal to 1. If an invalid value is detected (like text, negative numbers, decimals, or zero), the system defaults to 1 approval and shows a validation error. The change includes tests to verify this behavior works correctly with various invalid inputs. This enhancement makes the security policy editor more robust by preventing users from entering invalid approval requirements.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
before.mov after.mov

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Go to Group/Project
  2. Secure -> Policies
  3. New approval policy
  4. Switch to yaml mode, type in invalid value in approvals_required
  5. Switch to rule mode

Related to #428689 (closed)

Merge request reports

Loading