Conditional Regex Validator Control
Custom Azure DevOps Work Item Form control that validates a target field against a regex pattern when a configurable condition is active.
Features
- Works as a custom control contribution (
ms.vss-work-web.work-item-form-control).
- Conditional activation based on another field value.
- Regex-based validation for the target field.
- Optional required behavior when the condition is active.
- Clear status feedback in the UI:
- Validation inactive
- Required
- Empty but allowed
- Invalid regex configuration
- Invalid
- Valid
TargetFieldName (WorkItemField)
ConditionFieldName (WorkItemField, optional)
ConditionFieldValue (String)
RegexPattern (String)
ErrorMessage (String)
IsRequiredWhenActive (Boolean)
StatusFieldName (WorkItemField, optional)
StatusFieldValue (String, optional)
Example
TargetFieldName: Custom.ReleaseKey
ConditionFieldName: Custom.SourceType
ConditionFieldValue: External
RegexPattern: ^\d+\.\d+\.\d+\.[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$
ErrorMessage: ReleaseKey must match number.number.number.guid when SourceType = External
IsRequiredWhenActive: true
Installation
Install the extension in your Azure DevOps organization, then add the custom control to a Work Item Type layout in your inherited process.
| |