Skip to content

Add regex validation to string CI inputs

Avielle Wolfe requested to merge 410836-input-regex-validation into master

What does this MR do and why?

This MR adds a new optional regex keyword to CI inputs. It can be used to validate that string inputs match the given pattern. It errors when used with any other input type.

Changelog: added

Screenshots or screen recordings

Regex validation on value provided from .gitlab-ci.yml

This included file requires that the required_test input be given a string value composed only of letters

Screenshot_2023-09-26_at_14.33.13

When it is given a string with _, it shows an error message

Screenshot_2023-09-26_at_14.34.17

When it is given a string containing only letters, it passes validation

Screenshot_2023-09-26_at_14.05.43

Regex validation on default value

This included file requires that the default_test input be given a string value composed only of letters

Screenshot_2023-09-26_at_14.37.04

Because the default value contains a _, this input will be invalid if not given a value by the including file

Screenshot_2023-09-26_at_14.38.50

If it is given a valid value by the including file, it will pass

Screenshot_2023-09-26_at_14.39.55

Regex validation with invalid type

This included file attempts to use RegEx validation with a boolean input

Screenshot_2023-09-26_at_14.43.12

RegEx validation can only be used with string inputs, so the including file gets an error

Screenshot_2023-09-26_at_14.43.57

How to set up and validate locally

In any project locally, you can use the example configuration files above and check that you get the errors from the screenshots

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #410836 (closed)

Edited by Avielle Wolfe

Merge request reports