Description Validator
Validate PR description content and format
The Description Validator ensures that pull request descriptions meet specified requirements, such as minimum length, required sections, or specific content patterns. This helps maintain informative PR descriptions that provide adequate context for reviewers.
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
Retrieve Description
The validator retrieves the PR description from the GitHub event context
Check Empty
If no_empty
is true, checks if the description is empty
Check Length
If length
is specified, verifies the description length is within the specified range
Check Pattern
If match
is specified, checks if the description matches any of the regex patterns
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
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
This way, contributors automatically get a template that helps them meet your requirements.