Configuration
Must be set to
"description"
Whether empty descriptions are allowed (true = not allowed)
Description length constraints
Minimum description length in characters
Maximum description length in characters
Regex pattern(s) that the description should match
Custom message to display when validation fails
Basic Usage
Examples
Require Non-Empty Description
Ensure PR descriptions aren’t empty:Minimum Description Length
Require detailed descriptions:Pattern Matching
Require specific sections in the description:Multiple Requirements
Combine multiple requirements:Pattern Matching
The Description Validator uses JavaScript regular expressions for pattern matching:- Patterns are case-sensitive by default
- Use
i
flag for case-insensitive matching:"/pattern/i"
- You can specify multiple patterns as an array
- Pattern matching is done against the entire description
How It Works
1
Retrieve Description
The validator retrieves the PR description from the GitHub event context
2
Check Empty
If
no_empty
is true, checks if the description is empty3
Check Length
If
length
is specified, verifies the description length is within the specified range4
Check Pattern
If
match
is specified, checks if the description matches any of the regex patterns5
Return Result
Returns a validation result with status (pass, fail, or error) and a message
Practical Use Cases
Structured Description Template
Enforce a structured PR description format:Issue Reference Check
Ensure PR descriptions reference an issue:Testing Information
Require information about testing:Different Requirements by Branch
Apply stricter requirements for production branches:Best Practices
Provide a PR template to guide contributors
Keep requirements reasonable and aligned with your team’s workflow
Give clear feedback when validation fails
Consider different requirements for different types of changes
Very strict requirements might frustrate contributors, especially for simple changes
Template Integration
To maximize effectiveness, combine this validator with a PR template in your repository:- Create a file at
.github/PULL_REQUEST_TEMPLATE.md
- Include the required sections and guidance
- Configure the validator to check for these sections