# RegEx validation for Step Input

**URL:** <https://forum.buildkite.community/t/regex-validation-for-step-input/1260>\
**Category:** Features Requests\
**Created:** [October 2, 2020, 3:26pm UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260 "2020-10-02T15:26:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![noizwaves](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@noizwaves](https://forum.buildkite.community/u/noizwaves)\
**Post date:** [October 2, 2020, 3:26pm UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/1 "2020-10-02T15:26:51Z")

</div>

We’re currently using an input step with text inputs to gather some deployment information, and often users will enter invalid values.

It would be great to associate a RegEx to a field and have the field outline turn red when an invalid value is entered.

Our validation occurs occurs in subsequent steps, and the only way we can return validation errors is by failing the build and printing an error styled annotation. This is extremely noisy for us operationally, as we have notifications set up to notify us of build failures. We want to know when a deployment fails, but we’re currently being overwhelmed with validation failures.

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [October 13, 2020, 6:05am UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/2 "2020-10-13T06:05:23Z")

</div>

This sounds like a neat idea! We’ll take a look when we can.

---

<div class="post-metadata">

**Author:** ![sj26](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/sj26/32/17_2.png) [@sj26](https://forum.buildkite.community/u/sj26)\
**Post date:** [October 26, 2020, 12:22am UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/3 "2020-10-26T00:22:22Z")

</div>

We’ve had a go at this, with a syntax like this:

```auto
steps:
- block: "Click me!"
  fields:
  - text: Must be hexadecimal
    key: hex
    format: "[0-9a-f]+"

```

`format` must be a regular expression which will be implicitly anchored to the beginning and end of the input, and is functionally equivalent to the HTML5 pattern attribute:

> **[HTML attribute: pattern](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern)**
>
> The pattern attribute specifies a regular expression the form control's value should match. If a non-null value doesn't conform to the constraints set by the pattern value, the  ValidityState object's read-only patternMismatch property will be...

Let us know if it works for you?

(It’s still deploying, but should be available in a few minutes.)

---

<div class="post-metadata">

**Author:** ![noizwaves](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@noizwaves](https://forum.buildkite.community/u/noizwaves)\
**Post date:** [October 26, 2020, 8:49pm UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/4 "2020-10-26T20:49:40Z")

</div>

I can’t think you enough for landing this seemingly small change. One of the pipeline’s my team administers performs input validation on some fields. Previously, we had to do it all in Bash scripts, and validation errors would result in build failures and noisy error notifications to the team.

Thanks for helping us create better user experiences!

---

<div class="post-metadata">

**Author:** ![quentinp](https://avatars.discourse-cdn.com/v4/letter/q/ba9def/32.png) [@quentinp](https://forum.buildkite.community/u/quentinp)\
**Post date:** [June 28, 2023, 12:22pm UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/5 "2023-06-28T12:22:22Z")

</div>

This is really good, thanks! Would you mind documenting it?

---

<div class="post-metadata">

**Author:** ![karen.sawrey](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/karen.sawrey/32/1188_2.png) [@karen.sawrey](https://forum.buildkite.community/u/karen.sawrey)\
**Post date:** [June 28, 2023, 1:37pm UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/6 "2023-06-28T13:37:52Z")

</div>

Hello, @quentinp! Welcome to the community!

Thank you for this suggestion! We’ll update the docs.

Cheers!

Karen

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [August 29, 2023, 5:39am UTC](https://forum.buildkite.community/t/regex-validation-for-step-input/1260/7 "2023-08-29T05:39:29Z")

</div>


